Skip to content
This page View Markdown Open in ChatGPT Open in Claude

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
1
2
3
4
5
6
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
1
2
3
4
5
6
7
8
9
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"
    }
});

removeById [header]

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
1
2
3
4
let removeById = await g.sys.db.gen.removeByIdGen({
    instance: "crm::acme", database: "crm", collection: "customers",
    id: 101
});