Code examples
/
Generated APIs (g.sys.db.gen)
Distinct
g.sys.db.gen.distinctGen calls the distinct generated API from your code : no schema, the data as it is in the table.
Structure
Distinct method let distinct = await g . sys . db . gen . distinctGen ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
distinctField : "COLUMN_NAME" ,
order : "asc"
});
Simple distinct
Simple distinct let distinct = await g . sys . db . gen . distinctGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
distinctField : "first_name"
});
distinct with header let distinct = await g . sys . db . gen . distinctGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
distinctField : "first_name" ,
headers : {
"x-am-response-case" : "capitalCase"
}
});
distinct with order
ascending
distinct with order let distinct = await g . sys . db . gen . distinctGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
distinctField : "first_name" ,
order : "asc"
});
descending
distinct with header let distinct = await g . sys . db . gen . distinctGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
distinctField : "first_name" ,
order : "desc"
});
distinct with headers and order
distinct with header & order let distinct = await g . sys . db . gen . distinctGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
distinctField : "first_name" ,
headers : {
"x-am-response-case" : "capitalCase"
},
order : "asc"
});
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.
Distinct first names of the customers of the tenant acme let distinct = await g . sys . db . gen . distinctGen ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
distinctField : "first_name"
});