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

Remove by id

The code in every language

Each example is the inside of main, written in every language API Maker runs : pick yours in the tabs, and every page shows it from then on. The types a call takes (GetAll, DeepItem…) are those of am : from am import GetAll in Python, use am::GetAll; in Rust, import am.GetAll; in Java and Kotlin ; PHP and C# have them without an import, Go names them am.GetAll.

g.sys.db.removeById calls the remove by id schema API of any table from your code, with the same headers and query parameters as over HTTP. It returns the data. The whole envelope (success, statusCode, data, totalCount, errors…) comes back when true is passed as the second argument in TypeScript, and through full in the other languages : g.sys.db.full (g.Sys.Db.Full in C# and Go, $g->sys->db->full in PHP).

Remove By Id

Remove By Id
1
2
3
4
let removeById = await g.sys.db.removeById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: 101
});
Remove By Id
1
2
3
4
remove_by_id = await g.sys.db.remove_by_id(
    'mysql_8', 'inventory', 'customers',
    101,
)
Remove By Id
1
2
3
4
$removeById = $g->sys->db->removeById(
    'mysql_8', 'inventory', 'customers',
    101,
);
Remove By Id
var removeById = await g.Sys.Db.RemoveById(new RemoveById("mysql_8", "inventory", "customers", 101));
Remove By Id
1
2
3
4
5
6
7
removeById, err := g.Sys.Db.RemoveById(am.RemoveById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id: 101,
})
if err != nil {
    return nil, err
}
Remove By Id
let remove_by_id = g.sys.db.remove_by_id(RemoveById::new("mysql_8", "inventory", "customers", json!(101)))?;
Remove By Id
var removeById = g.sys.db.removeById(new RemoveById("mysql_8", "inventory", "customers", 101));
Remove By Id
val removeById = g.sys.db.removeById(RemoveById("mysql_8", "inventory", "customers", 101))

Remove By Id [primaryKey] override

Remove By Id primary key override
1
2
3
4
5
let removeById = await g.sys.db.removeById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: "Bob",
    primaryKey: "first_name"
});
Remove By Id primary key override
1
2
3
4
5
remove_by_id = await g.sys.db.remove_by_id(
    'mysql_8', 'inventory', 'customers',
    'Bob',
    primary_key='first_name',
)
Remove By Id primary key override
1
2
3
4
5
$removeById = $g->sys->db->removeById(
    'mysql_8', 'inventory', 'customers',
    'Bob',
    primaryKey: 'first_name',
);
Remove By Id primary key override
1
2
3
4
var removeById = await g.Sys.Db.RemoveById(new RemoveById("mysql_8", "inventory", "customers", "Bob")
{
    PrimaryKey = "first_name",
});
Remove By Id primary key override
1
2
3
4
5
6
7
8
removeById, err := g.Sys.Db.RemoveById(am.RemoveById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id:         "Bob",
    PrimaryKey: "first_name",
})
if err != nil {
    return nil, err
}
Remove By Id primary key override
1
2
3
4
let remove_by_id = g.sys.db.remove_by_id(
    RemoveById::new("mysql_8", "inventory", "customers", "Bob")
        .primary_key("first_name"),
)?;
Remove By Id primary key override
var removeById = g.sys.db.removeById(new RemoveById("mysql_8", "inventory", "customers", "Bob")
    .primaryKey("first_name"));
Remove By Id primary key override
1
2
3
4
val removeById = g.sys.db.removeById(
    RemoveById("mysql_8", "inventory", "customers", "Bob")
        .primaryKey("first_name"),
)

removeById [header]

Remove By Id header
1
2
3
4
5
6
7
8
let removeById = await g.sys.db.removeById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: "Bob",
    primaryKey: "first_name",
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
});
Remove By Id header
1
2
3
4
5
6
7
8
remove_by_id = await g.sys.db.remove_by_id(
    'mysql_8', 'inventory', 'customers',
    'Bob',
    primary_key='first_name',
    headers={
        'x-am-response-case': 'capitalCase',  # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
)
Remove By Id header
1
2
3
4
5
6
7
8
$removeById = $g->sys->db->removeById(
    'mysql_8', 'inventory', 'customers',
    'Bob',
    primaryKey: 'first_name',
    headers: [
        'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    ],
);
Remove By Id header
1
2
3
4
5
6
7
8
var removeById = await g.Sys.Db.RemoveById(new RemoveById("mysql_8", "inventory", "customers", "Bob")
{
    PrimaryKey = "first_name",
    Headers = new JsonObject
    {
        ["x-am-response-case"] = "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
});
Remove By Id header
removeById, err := g.Sys.Db.RemoveById(am.RemoveById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id:         "Bob",
    PrimaryKey: "first_name",
    Headers: am.M{
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
})
if err != nil {
    return nil, err
}
Remove By Id header
1
2
3
4
5
6
7
let remove_by_id = g.sys.db.remove_by_id(
    RemoveById::new("mysql_8", "inventory", "customers", "Bob")
        .primary_key("first_name")
        .headers(json!({
            "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        })),
)?;
Remove By Id header
1
2
3
4
5
var removeById = g.sys.db.removeById(new RemoveById("mysql_8", "inventory", "customers", "Bob")
    .primaryKey("first_name")
    .headers(Map.of(
        "x-am-response-case", "capitalCase" // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    )));
Remove By Id header
1
2
3
4
5
6
7
val removeById = g.sys.db.removeById(
    RemoveById("mysql_8", "inventory", "customers", "Bob")
        .primaryKey("first_name")
        .headers(mapOf(
            "x-am-response-case" to "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        )),
)

Structure

Remove by id with all params
let removeById = await g.sys.db.removeById({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
    id: 7878,
    primaryKey: "COLUMN_NAME",
    select: "COMMA_SEPARATED_COLUMN_NAMES",
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        "x-am-response-object-type": "make_flat", // no_action | make_flat
        "x-am-meta": "true", // true, false
        "x-am-internationalization": "USER_I18N_ID",
        "x-am-run-in-sandbox": "2",
        "x-am-content-type-response": "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        "x-am-cache-control": "reset_cache", // no_action | reset_cache
        "x-am-get-encrypted-data": "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        "x-am-sandbox-timeout": "13000",
        "x-no-compression": "true", // true | false
        "x-am-encrypted-payload": "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        "x-am-tenant-username": "TENANT_USERNAME", // ex: acme
        // Authorization headers
        "x-am-authorization": "AUTHORIZATION_TOKEN",
        "x-am-user-authorization": "API_USER_TOKEN",
        "x-aws-authorization": "AWS_TOKEN",
        "x-google-authorization": "GOOGLE_TOKEN",
        "x-azure-authorization": "AZURE_TOKEN",
    },
});
Remove by id with all params
remove_by_id = await g.sys.db.remove_by_id(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    7878,
    primary_key='COLUMN_NAME',
    select='COMMA_SEPARATED_COLUMN_NAMES',
    headers={
        'x-am-response-case': 'capitalCase',  # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        'x-am-response-object-type': 'make_flat',  # no_action | make_flat
        'x-am-meta': 'true',  # true, false
        'x-am-internationalization': 'USER_I18N_ID',
        'x-am-run-in-sandbox': '2',
        'x-am-content-type-response': 'text/xml',  # application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        'x-am-cache-control': 'reset_cache',  # no_action | reset_cache
        'x-am-get-encrypted-data': 'get_only_encryption',  # no_encryption | get_only_encryption | get_data_and_encryption
        'x-am-sandbox-timeout': '13000',
        'x-no-compression': 'true',  # true | false
        'x-am-encrypted-payload': 'true',  # user will send 'true', when payload is encrypted for transfer
        # Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        'x-am-tenant-username': 'TENANT_USERNAME',  # ex: acme
        # Authorization headers
        'x-am-authorization': 'AUTHORIZATION_TOKEN',
        'x-am-user-authorization': 'API_USER_TOKEN',
        'x-aws-authorization': 'AWS_TOKEN',
        'x-google-authorization': 'GOOGLE_TOKEN',
        'x-azure-authorization': 'AZURE_TOKEN',
    },
)
Remove by id with all params
$removeById = $g->sys->db->removeById(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    7878,
    primaryKey: 'COLUMN_NAME',
    select: 'COMMA_SEPARATED_COLUMN_NAMES',
    headers: [
        'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        'x-am-response-object-type' => 'make_flat', // no_action | make_flat
        'x-am-meta' => 'true', // true, false
        'x-am-internationalization' => 'USER_I18N_ID',
        'x-am-run-in-sandbox' => '2',
        'x-am-content-type-response' => 'text/xml', // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        'x-am-cache-control' => 'reset_cache', // no_action | reset_cache
        'x-am-get-encrypted-data' => 'get_only_encryption', // no_encryption | get_only_encryption | get_data_and_encryption
        'x-am-sandbox-timeout' => '13000',
        'x-no-compression' => 'true', // true | false
        'x-am-encrypted-payload' => 'true', // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        'x-am-tenant-username' => 'TENANT_USERNAME', // ex: acme
        // Authorization headers
        'x-am-authorization' => 'AUTHORIZATION_TOKEN',
        'x-am-user-authorization' => 'API_USER_TOKEN',
        'x-aws-authorization' => 'AWS_TOKEN',
        'x-google-authorization' => 'GOOGLE_TOKEN',
        'x-azure-authorization' => 'AZURE_TOKEN',
    ],
);
Remove by id with all params
var removeById = await g.Sys.Db.RemoveById(new RemoveById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 7878)
{
    PrimaryKey = "COLUMN_NAME",
    Select = "COMMA_SEPARATED_COLUMN_NAMES",
    Headers = new JsonObject
    {
        ["x-am-response-case"] = "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        ["x-am-response-object-type"] = "make_flat", // no_action | make_flat
        ["x-am-meta"] = "true", // true, false
        ["x-am-internationalization"] = "USER_I18N_ID",
        ["x-am-run-in-sandbox"] = "2",
        ["x-am-content-type-response"] = "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        ["x-am-cache-control"] = "reset_cache", // no_action | reset_cache
        ["x-am-get-encrypted-data"] = "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        ["x-am-sandbox-timeout"] = "13000",
        ["x-no-compression"] = "true", // true | false
        ["x-am-encrypted-payload"] = "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        ["x-am-tenant-username"] = "TENANT_USERNAME", // ex: acme
        // Authorization headers
        ["x-am-authorization"] = "AUTHORIZATION_TOKEN",
        ["x-am-user-authorization"] = "API_USER_TOKEN",
        ["x-aws-authorization"] = "AWS_TOKEN",
        ["x-google-authorization"] = "GOOGLE_TOKEN",
        ["x-azure-authorization"] = "AZURE_TOKEN",
    },
});
Remove by id with all params
removeById, err := g.Sys.Db.RemoveById(am.RemoveById{
    Instance: "INSTANCE_NAME", Database: "DB_NAME", Collection: "COLLECTION_NAME",
    Id:         7878,
    PrimaryKey: "COLUMN_NAME",
    Select:     "COMMA_SEPARATED_COLUMN_NAMES",
    Headers: am.M{
        "x-am-response-case":         "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        "x-am-response-object-type":  "make_flat",   // no_action | make_flat
        "x-am-meta":                  "true",        // true, false
        "x-am-internationalization":  "USER_I18N_ID",
        "x-am-run-in-sandbox":        "2",
        "x-am-content-type-response": "text/xml",            // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        "x-am-cache-control":         "reset_cache",         // no_action | reset_cache
        "x-am-get-encrypted-data":    "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        "x-am-sandbox-timeout":       "13000",
        "x-no-compression":           "true", // true | false
        "x-am-encrypted-payload":     "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        "x-am-tenant-username": "TENANT_USERNAME", // ex: acme
        // Authorization headers
        "x-am-authorization":      "AUTHORIZATION_TOKEN",
        "x-am-user-authorization": "API_USER_TOKEN",
        "x-aws-authorization":     "AWS_TOKEN",
        "x-google-authorization":  "GOOGLE_TOKEN",
        "x-azure-authorization":   "AZURE_TOKEN",
    },
})
if err != nil {
    return nil, err
}
Remove by id with all params
let remove_by_id = g.sys.db.remove_by_id(
    RemoveById::new("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", json!(7878))
        .primary_key("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .headers(json!({
            "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
            "x-am-response-object-type": "make_flat", // no_action | make_flat
            "x-am-meta": "true", // true, false
            "x-am-internationalization": "USER_I18N_ID",
            "x-am-run-in-sandbox": "2",
            "x-am-content-type-response": "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
            "x-am-cache-control": "reset_cache", // no_action | reset_cache
            "x-am-get-encrypted-data": "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
            "x-am-sandbox-timeout": "13000",
            "x-no-compression": "true", // true | false
            "x-am-encrypted-payload": "true", // user will send 'true', when payload is encrypted for transfer
            // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
            "x-am-tenant-username": "TENANT_USERNAME", // ex: acme
            // Authorization headers
            "x-am-authorization": "AUTHORIZATION_TOKEN",
            "x-am-user-authorization": "API_USER_TOKEN",
            "x-aws-authorization": "AWS_TOKEN",
            "x-google-authorization": "GOOGLE_TOKEN",
            "x-azure-authorization": "AZURE_TOKEN",
        })),
)?;
Remove by id with all params
var removeById = g.sys.db.removeById(new RemoveById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 7878)
    .primaryKey("COLUMN_NAME")
    .select("COMMA_SEPARATED_COLUMN_NAMES")
    .headers(JsonObject.of(
        "x-am-response-case", "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        "x-am-response-object-type", "make_flat", // no_action | make_flat
        "x-am-meta", "true", // true, false
        "x-am-internationalization", "USER_I18N_ID",
        "x-am-run-in-sandbox", "2",
        "x-am-content-type-response", "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        "x-am-cache-control", "reset_cache", // no_action | reset_cache
        "x-am-get-encrypted-data", "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        "x-am-sandbox-timeout", "13000",
        "x-no-compression", "true", // true | false
        "x-am-encrypted-payload", "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        "x-am-tenant-username", "TENANT_USERNAME", // ex: acme
        // Authorization headers
        "x-am-authorization", "AUTHORIZATION_TOKEN",
        "x-am-user-authorization", "API_USER_TOKEN",
        "x-aws-authorization", "AWS_TOKEN",
        "x-google-authorization", "GOOGLE_TOKEN",
        "x-azure-authorization", "AZURE_TOKEN"
    )));
Remove by id with all params
val removeById = g.sys.db.removeById(
    RemoveById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 7878)
        .primaryKey("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .headers(mapOf(
            "x-am-response-case" to "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
            "x-am-response-object-type" to "make_flat", // no_action | make_flat
            "x-am-meta" to "true", // true, false
            "x-am-internationalization" to "USER_I18N_ID",
            "x-am-run-in-sandbox" to "2",
            "x-am-content-type-response" to "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
            "x-am-cache-control" to "reset_cache", // no_action | reset_cache
            "x-am-get-encrypted-data" to "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
            "x-am-sandbox-timeout" to "13000",
            "x-no-compression" to "true", // true | false
            "x-am-encrypted-payload" to "true", // user will send 'true', when payload is encrypted for transfer
            // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
            "x-am-tenant-username" to "TENANT_USERNAME", // ex: acme
            // Authorization headers
            "x-am-authorization" to "AUTHORIZATION_TOKEN",
            "x-am-user-authorization" to "API_USER_TOKEN",
            "x-aws-authorization" to "AWS_TOKEN",
            "x-google-authorization" to "GOOGLE_TOKEN",
            "x-azure-authorization" to "AZURE_TOKEN",
        )),
)

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.removeById({
    instance: "crm::acme", database: "crm", collection: "customers",
    id: 101
});
Remove the customer 101 of the tenant acme
1
2
3
4
remove_by_id = await g.sys.db.remove_by_id(
    'crm::acme', 'crm', 'customers',
    101,
)
Remove the customer 101 of the tenant acme
1
2
3
4
$removeById = $g->sys->db->removeById(
    'crm::acme', 'crm', 'customers',
    101,
);
Remove the customer 101 of the tenant acme
var removeById = await g.Sys.Db.RemoveById(new RemoveById("crm::acme", "crm", "customers", 101));
Remove the customer 101 of the tenant acme
1
2
3
4
5
6
7
removeById, err := g.Sys.Db.RemoveById(am.RemoveById{
    Instance: "crm::acme", Database: "crm", Collection: "customers",
    Id: 101,
})
if err != nil {
    return nil, err
}
Remove the customer 101 of the tenant acme
let remove_by_id = g.sys.db.remove_by_id(RemoveById::new("crm::acme", "crm", "customers", json!(101)))?;
Remove the customer 101 of the tenant acme
var removeById = g.sys.db.removeById(new RemoveById("crm::acme", "crm", "customers", 101));
Remove the customer 101 of the tenant acme
val removeById = g.sys.db.removeById(RemoveById("crm::acme", "crm", "customers", 101))

Without a schema

g.sys.db.gen.removeByIdGen takes the same arguments and calls the remove by id generated API : no schema, so the data is read and written as it is in the table, without the conversions, validations and defaults of the schema.

Language The call
TypeScript g.sys.db.gen.removeByIdGen(…)
Python g.sys.db.gen.remove_by_id_gen(…)
PHP $g->sys->db->gen->removeByIdGen(…)
C#, Go g.Sys.Db.Gen.RemoveByIdGen(…)
Rust g.sys.db.remove_by_id_gen(RemoveById::new(…))
Java, Kotlin g.sys.db.gen.removeByIdGen(…)