Code examples
/
Generated APIs (g.sys.db.gen)
Get all
g.sys.db.gen.getAllGen calls the get all generated API from your code : no schema, the data as it is in the table.
Structure
Structure let getAll = await g . sys . db . gen . getAllGen ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
queryParams : {
deep : JSON.stringify ([{
s_key : "SOURCE_COLLECTION_COLUMN_NAME" ,
t_key : "TARGET_COLLECTION_COLUMN_NAME" ,
t_col : "TARGET_COLLECTION_NAME" ,
select : "COLUMN_NAMES"
}]),
select : "COLUMN_NAMES" ,
limit : 2 ,
sort : "COLUMN_NAME"
}
});
Simple Get all with one condition
Simple Get all from table let getAll = await g . sys . db . gen . getAllGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
queryParams : {
find : {
first_name : 'James'
}
}
});
Get all with header let getAll = await g . sys . db . gen . getAllGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
}
});
With header and queryParams
Get all with header and queryParams let getAll = await g . sys . db . gen . getAllGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-meta" : "true"
},
queryParams : {
select : "first_name,last_name"
}
});
With multiple queryParams
Get all with multiple queryParams let getAll = await g . sys . db . gen . getAllGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
},
queryParams : {
select : "first_name,last_name" ,
limit : 2
}
});
With all params
Get all with all params let getAll = await g . sys . db . gen . getAllGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
},
queryParams : {
select : "first_name,last_name" ,
limit : 1 ,
sort : "customer_id" ,
deep : [{
s_key : "customer_id" ,
t_key : "owner_id" ,
t_col : "products" ,
select : "proName,proDescription,proPrice"
}]
}
});
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 let getAll = await g . sys . db . gen . getAllGen ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
queryParams : {
sort : "customer_id"
}
});
Get all customers of the tenant globex, named with the header of the call let getAll = await g . sys . db . gen . getAllGen ({
instance : "crm" , database : "crm" , collection : "customers" ,
headers : {
"x-am-tenant-username" : "globex"
}
});