-
Notifications
You must be signed in to change notification settings - Fork 791
Closed
Labels
Description
I have been trying to create a client using the generated js from a proto file that i have. This is the proto file example
service Database {
rpc get_rows(rows_request) returns (rows_return);
}
message filter
{
TableNames table = 1;
string field_name = 2;
DbOperatorType operation_type = 3;
repeated string filter_value = 4;
}
message rows_request
{
TableNames table = 1; ///name of the table
uint32 limit = 2; /// number of max results
uint32 offset = 3; /// offset the results
repeated filter filter = 4;
repeated OrderBy order = 5;
}
enum DbOperatorType
{
DB_EQUAL=0;
DB_NOT_EQUAL=1;
DB_LESS=2;
DB_LESS_OR_EQUAL=3;
DB_GREATER_THAN=4;
DB_GREATER_THAN_OR_EQUAL=5;
DB_BETWEEN=6;
DB_NOT_BETWEEN=7;
DB_ILIKE=8;
DB_NOT_ILIKE=9;
DB_IN=10;
DB_NOT_IN=11;
}
message OrderBy
{
string name = 1; /// field name
OrderByType type = 2; /// type of order ASC or DSC
TableNames table = 3; ///name of the table
}
enum OrderByType
{
ASC = 0; /// Ascended order
DSC = 1; /// Descended order
}
etc. etc.
and this is my client
const client = new DatabasePromiseClient("http"//url", null, null);
export const getRows = (params) => {
console.log("CALLEDDDD")
let request = new rows_request();
request.setTable(params.table);
request.setLimit(params.limit);
request.setOffset(params.offset);
if (Array.isArray(params.filter) && params.filter.length > 0) {
console.log("ENTER FILTER SETUP")
params.filter.forEach( filterItem => {
let filterRequest = new ProtoFilter();
filterRequest.setFieldName(filterItem.fieldName);
filterRequest.setOperationType(filterItem.operationType);
filterItem.filterValue.forEach( filterValue => {
filterRequest.addFilterValue(filterValue);
})
request.addFilter(filterRequest);
})
}
if (Array.isArray(params.order) && params.order.length > 0) {
console.log("ENTER ORDER SETUP")
params.order.forEach( orderItem => {
console.log(orderItem)
let orderRequest = new OrderBy();
orderRequest.setName(orderItem.name);
orderRequest.setType(orderItem.type);
orderRequest.setTable(params.table);
request.addOrder(orderRequest);
})
}
console.log(request);
return client.get_rows(request, {});
}
whenever i call the getRows function it gives me error
Error: Assertion failed
at __webpack_modules__../node_modules/google-protobuf/google-protobuf.js.jspb.asserts.doAssertFailure (google-protobuf.js:88:1)
at __webpack_modules__../node_modules/google-protobuf/google-protobuf.js.jspb.asserts.assert (google-protobuf.js:88:1)
at __webpack_modules__../node_modules/google-protobuf/google-protobuf.js.jspb.BinaryWriter.writeEnum (google-protobuf.js:470:1)
at proto.service.rows_request.serializeBinaryToWriter (service_pb.js:7042:1)
I already checked on what i pass and they are matching with the enum that was setup. and the debugging is a bit hard since it fails even before sending the request to the server. can Anyone help me? Thanks!