Code examples
/
Generated APIs (g.sys.db.gen)
Remove by id
g.sys.db.gen.removeByIdGen calls the remove by id generated API from your code : no schema, the data as it is in the table.
Structure
Remove by id let removeById = await g . sys . db . gen . removeByIdGen ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
select : "COLUMN_NAMES" ,
id : 7878 ,
primaryKey : "COLUMN_NAME"
});
Simple removeById
Remove By Id let updateById = await g . sys . db . gen . removeByIdGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
id : 1 ,
updateData : {
"first_name" : "MALLORY"
}
});
removeById primaryKey override
Remove By Id primarykey override let updateById = await g . sys . db . gen . removeByIdGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
id : "Bob" ,
primaryKey : "first_name" ,
updateData : {
"first_name" : "MALLORY"
}
});
Remove By Id header let updateById = await g . sys . db . gen . removeByIdGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
id : "Bob" ,
primaryKey : "first_name" ,
updateData : {
"first_name" : "MALLORY"
},
headers : {
"x-am-response-case" : "capitalCase"
}
});
removeById [select]
Remove By Id header let updateById = await g . sys . db . gen . removeByIdGen ({
instance : "mysql_8" ,
database : "inventory" ,
collection : "customers" ,
id : "Bob" ,
primaryKey : "first_name" ,
updateData : {
"first_name" : "MALLORY"
},
select : "first_name,last_name"
});
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.
Remove the customer 101 of the tenant acme let removeById = await g . sys . db . gen . removeByIdGen ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
id : 101
});