Code examples
/
Generated APIs (g.sys.db.gen)
Get all by stream
g.sys.db.gen.getAllByStreamGen calls the get all by stream generated API from your code : no schema, the data as it is in the table.
Structure
Get all by stream let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
queryParams : {
deep : `[{
s_key: "SOURCE_COLLECTION_COLUMN_NAME",
t_key: "TARGET_COLLECTION_COLUMN_NAME",
t_col: "TARGET_COLLECTION_NAME",
select: "COLUMN_NAMES"
}]` ,
select : "COLUMN_NAMES" ,
sort : "-COLUMN_NAME" ,
limit : 2 ,
find : `{"price": 42187}` ,
skip : 1 ,
}
}, ( item ) => {
response . push ( item );
});
Simple Get all
Simple Get all from table let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
}, ( item ) => {
response . push ( item );
});
Get all with header let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
}
}, ( item ) => {
response . push ( item );
});
With header and queryParams
Get all with header and queryParams let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
},
queryParams : {
select : "first_name,last_name"
}
}, ( item ) => {
response . push ( item );
});
With multiple queryParams
Get all With multiple queryParams let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
},
queryParams : {
select : "first_name,last_name" ,
limit : 2
}
}, ( item ) => {
response . push ( item );
});
With all params
Get all With all params let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
},
queryParams : {
select : "first_name,last_name" ,
limit : 1 ,
sort : "customer_id" ,
}
}, ( item ) => {
response . push ( item );
});
Multi-tenant
instance: "crm::acme" works on the database of the tenant acme of the multi-tenant instance crm.
With instance: "crm", the call works on the database of the tenant of the request: a custom API called with the x-am-tenant-username header passes it on to the APIs it calls. A request without a tenant works on the structure database.
Get all customers of the tenant acme by stream let response = [];
await g . sys . db . gen . getAllByStreamGen ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
}, ( item ) => {
response . push ( item );
});