Code examples
/
Generated APIs (g.sys.db.gen)
Count
g.sys.db.gen.countGen calls the count generated API from your code : no schema, the data as it is in the table.
Structure
Count method let count = await g . sys . db . gen . countGen ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
find : {
"pincode" : 100050
}
});
Simple get count
Simple get count let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers"
});
Simple headers let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
headers : {
"x-am-response-case" : "capitalCase"
}
});
Simple find
Simple find let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : "Bob"
}
});
$gt
$gt let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$gt" : 4
}
}
});
$gte
$gte let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$gte" : 4
}
}
});
$lt
$lt let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$lt" : 4
}
}
});
$lte
$lte let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$lte" : 4
}
}
});
$eq
$eq let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : {
"$eq" : "Bob"
}
}
});
$ne
$ne let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : {
"$ne" : "Bob"
}
}
});
$in
$in let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$in" : [ 1 , 2 ]
}
}
});
$nin
$nin let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$nin" : [ 1 , 2 ]
}
}
});
$and
$and let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"$and" : [
{
"employee_Details.emp_Id" : 1
},
{
"city" : "Baroda"
}
]
}
});
$or
$or let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"$or" : [
{
"employee_Details.emp_Id" : 1
},
{
"city" : "Baroda"
}
]
}
});
$like
$like let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : {
"$like" : "%Mall%"
}
}
});
% after text
% after text let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : {
"$like" : "Mall%"
}
}
});
count with multiple column
count with multiple column let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : "Mallory" ,
"last_name" : "Brown"
}
});
count with multiple column
count with multiple column let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"first_name" : "Mallory" ,
"last_name" : "Brown"
}
});
floating value support
floating value support let count = await g . sys . db . gen . countGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
find : {
"isActive" : {
"$gt" : 2.2
}
}
});
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.
Count the customers of the tenant acme let count = await g . sys . db . gen . countGen ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
find : {
"first_name" : "Bob"
}
});