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

Update 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.updateById calls the update 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).

Update by id

Update By Id
1
2
3
4
5
6
7
let updateById = await g.sys.db.updateById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: 1,
    updateData: {
        "first_name": "MALLORY"
    }
});
Update By Id
1
2
3
4
5
6
7
update_by_id = await g.sys.db.update_by_id(
    'mysql_8', 'inventory', 'customers',
    1,
    update_data={
        'first_name': 'MALLORY',
    },
)
Update By Id
1
2
3
4
5
6
7
$updateById = $g->sys->db->updateById(
    'mysql_8', 'inventory', 'customers',
    1,
    updateData: [
        'first_name' => 'MALLORY',
    ],
);
Update By Id
1
2
3
4
5
6
7
var updateById = await g.Sys.Db.UpdateById(new UpdateById("mysql_8", "inventory", "customers", 1)
{
    UpdateData = new JsonObject
    {
        ["first_name"] = "MALLORY",
    },
});
Update By Id
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id: 1,
    UpdateData: am.M{
        "first_name": "MALLORY",
    },
})
if err != nil {
    return nil, err
}
Update By Id
1
2
3
4
5
6
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("mysql_8", "inventory", "customers", json!(1))
        .update_data(json!({
            "first_name": "MALLORY",
        })),
)?;
Update By Id
1
2
3
4
var updateById = g.sys.db.updateById(new UpdateById("mysql_8", "inventory", "customers", 1)
    .updateData(Map.of(
        "first_name", "MALLORY"
    )));
Update By Id
1
2
3
4
5
6
val updateById = g.sys.db.updateById(
    UpdateById("mysql_8", "inventory", "customers", 1)
        .updateData(mapOf(
            "first_name" to "MALLORY",
        )),
)

Update by id primaryKey override

Update By Id primarykey override
1
2
3
4
5
6
7
8
let updateById = await g.sys.db.updateById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    }
});
Update By Id primarykey override
1
2
3
4
5
6
7
8
update_by_id = await g.sys.db.update_by_id(
    'mysql_8', 'inventory', 'customers',
    'Alice',
    primary_key='first_name',
    update_data={
        'first_name': 'MALLORY',
    },
)
Update By Id primarykey override
1
2
3
4
5
6
7
8
$updateById = $g->sys->db->updateById(
    'mysql_8', 'inventory', 'customers',
    'Alice',
    primaryKey: 'first_name',
    updateData: [
        'first_name' => 'MALLORY',
    ],
);
Update By Id primarykey override
1
2
3
4
5
6
7
8
var updateById = await g.Sys.Db.UpdateById(new UpdateById("mysql_8", "inventory", "customers", "Alice")
{
    PrimaryKey = "first_name",
    UpdateData = new JsonObject
    {
        ["first_name"] = "MALLORY",
    },
});
Update By Id primarykey override
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id:         "Alice",
    PrimaryKey: "first_name",
    UpdateData: am.M{
        "first_name": "MALLORY",
    },
})
if err != nil {
    return nil, err
}
Update By Id primarykey override
1
2
3
4
5
6
7
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("mysql_8", "inventory", "customers", "Alice")
        .primary_key("first_name")
        .update_data(json!({
            "first_name": "MALLORY",
        })),
)?;
Update By Id primarykey override
1
2
3
4
5
var updateById = g.sys.db.updateById(new UpdateById("mysql_8", "inventory", "customers", "Alice")
    .primaryKey("first_name")
    .updateData(Map.of(
        "first_name", "MALLORY"
    )));
Update By Id primarykey override
1
2
3
4
5
6
7
val updateById = g.sys.db.updateById(
    UpdateById("mysql_8", "inventory", "customers", "Alice")
        .primaryKey("first_name")
        .updateData(mapOf(
            "first_name" to "MALLORY",
        )),
)

Update by id [upsert]

Update By Id with upsert
1
2
3
4
5
6
7
8
9
let updateById = await g.sys.db.updateById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: "202",
    updateData: {
        "first_name": "MALLORY",
        "last_name": "ANI"
    },
    upsert: true
});
Update By Id with upsert
1
2
3
4
5
6
7
8
9
update_by_id = await g.sys.db.update_by_id(
    'mysql_8', 'inventory', 'customers',
    '202',
    update_data={
        'first_name': 'MALLORY',
        'last_name': 'ANI',
    },
    upsert=True,
)
Update By Id with upsert
1
2
3
4
5
6
7
8
9
$updateById = $g->sys->db->updateById(
    'mysql_8', 'inventory', 'customers',
    '202',
    updateData: [
        'first_name' => 'MALLORY',
        'last_name' => 'ANI',
    ],
    upsert: true,
);
Update By Id with upsert
1
2
3
4
5
6
7
8
9
var updateById = await g.Sys.Db.UpdateById(new UpdateById("mysql_8", "inventory", "customers", "202")
{
    UpdateData = new JsonObject
    {
        ["first_name"] = "MALLORY",
        ["last_name"] = "ANI",
    },
    Upsert = true,
});
Update By Id with upsert
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id: "202",
    UpdateData: am.M{
        "first_name": "MALLORY",
        "last_name":  "ANI",
    },
    Upsert: true,
})
if err != nil {
    return nil, err
}
Update By Id with upsert
1
2
3
4
5
6
7
8
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("mysql_8", "inventory", "customers", "202")
        .update_data(json!({
            "first_name": "MALLORY",
            "last_name": "ANI",
        }))
        .upsert(true),
)?;
Update By Id with upsert
1
2
3
4
5
6
var updateById = g.sys.db.updateById(new UpdateById("mysql_8", "inventory", "customers", "202")
    .updateData(Map.of(
        "first_name", "MALLORY",
        "last_name", "ANI"
    ))
    .upsert(true));
Update By Id with upsert
1
2
3
4
5
6
7
8
val updateById = g.sys.db.updateById(
    UpdateById("mysql_8", "inventory", "customers", "202")
        .updateData(mapOf(
            "first_name" to "MALLORY",
            "last_name" to "ANI",
        ))
        .upsert(true),
)

Update by id [returnDocument]

Update By Id with returnDocument
1
2
3
4
5
6
7
8
let updateById = await g.sys.db.updateById({
    instance: "mysql_8", database: "inventory", collection: "customers",
    id: "202",
    updateData: {
        "first_name": "MALLORY"
    },
    returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
});
Update By Id with returnDocument
1
2
3
4
5
6
7
8
update_by_id = await g.sys.db.update_by_id(
    'mysql_8', 'inventory', 'customers',
    '202',
    update_data={
        'first_name': 'MALLORY',
    },
    return_document='before',  # return old doc if value 'before'. Supported values are 'before' | 'after'.
)
Update By Id with returnDocument
1
2
3
4
5
6
7
8
$updateById = $g->sys->db->updateById(
    'mysql_8', 'inventory', 'customers',
    '202',
    updateData: [
        'first_name' => 'MALLORY',
    ],
    returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
);
Update By Id with returnDocument
1
2
3
4
5
6
7
8
var updateById = await g.Sys.Db.UpdateById(new UpdateById("mysql_8", "inventory", "customers", "202")
{
    UpdateData = new JsonObject
    {
        ["first_name"] = "MALLORY",
    },
    ReturnDocument = "before", // return old doc if value 'before'. Supported values are 'before' | 'after'.
});
Update By Id with returnDocument
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Id: "202",
    UpdateData: am.M{
        "first_name": "MALLORY",
    },
    ReturnDocument: "before", // return old doc if value 'before'. Supported values are 'before' | 'after'.
})
if err != nil {
    return nil, err
}
Update By Id with returnDocument
1
2
3
4
5
6
7
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("mysql_8", "inventory", "customers", "202")
        .update_data(json!({
            "first_name": "MALLORY",
        }))
        .return_document("before"), // return old doc if value 'before'. Supported values are 'before' | 'after'.
)?;
Update By Id with returnDocument
1
2
3
4
5
var updateById = g.sys.db.updateById(new UpdateById("mysql_8", "inventory", "customers", "202")
    .updateData(Map.of(
        "first_name", "MALLORY"
    ))
    .returnDocument("before")); // return old doc if value 'before'. Supported values are 'before' | 'after'.
Update By Id with returnDocument
1
2
3
4
5
6
7
val updateById = g.sys.db.updateById(
    UpdateById("mysql_8", "inventory", "customers", "202")
        .updateData(mapOf(
            "first_name" to "MALLORY",
        ))
        .returnDocument("before"), // return old doc if value 'before'. Supported values are 'before' | 'after'.
)

Structure

Update by id with all params
let updateById = await g.sys.db.updateById({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
    id: 1008,
    primaryKey: "id",
    updateData: {
        "first_name": "Tanmay",
    },
    returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
    select: "COLUMN_NAMES",
    upsert: false,
    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",
    },
});
Update by id with all params
update_by_id = await g.sys.db.update_by_id(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    1008,
    primary_key='id',
    update_data={
        'first_name': 'Tanmay',
    },
    return_document='before',  # return old doc if value 'before'. Supported values are 'before' | 'after'.
    select='COLUMN_NAMES',
    upsert=False,
    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',
    },
)
Update by id with all params
$updateById = $g->sys->db->updateById(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    1008,
    primaryKey: 'id',
    updateData: [
        'first_name' => 'Tanmay',
    ],
    returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
    select: 'COLUMN_NAMES',
    upsert: false,
    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',
    ],
);
Update by id with all params
var updateById = await g.Sys.Db.UpdateById(new UpdateById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 1008)
{
    PrimaryKey = "id",
    UpdateData = new JsonObject
    {
        ["first_name"] = "Tanmay",
    },
    ReturnDocument = "before", // return old doc if value 'before'. Supported values are 'before' | 'after'.
    Select = "COLUMN_NAMES",
    Upsert = false,
    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",
    },
});
Update by id with all params
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "INSTANCE_NAME", Database: "DB_NAME", Collection: "COLLECTION_NAME",
    Id:         1008,
    PrimaryKey: "id",
    UpdateData: am.M{
        "first_name": "Tanmay",
    },
    ReturnDocument: "before", // return old doc if value 'before'. Supported values are 'before' | 'after'.
    Select:         "COLUMN_NAMES",
    Upsert:         false,
    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
}
Update by id with all params
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", json!(1008))
        .primary_key("id")
        .update_data(json!({
            "first_name": "Tanmay",
        }))
        .return_document("before") // return old doc if value 'before'. Supported values are 'before' | 'after'.
        .select("COLUMN_NAMES")
        .upsert(false)
        .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",
        })),
)?;
Update by id with all params
var updateById = g.sys.db.updateById(new UpdateById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 1008)
    .primaryKey("id")
    .updateData(Map.of(
        "first_name", "Tanmay"
    ))
    .returnDocument("before") // return old doc if value 'before'. Supported values are 'before' | 'after'.
    .select("COLUMN_NAMES")
    .upsert(false)
    .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"
    )));
Update by id with all params
val updateById = g.sys.db.updateById(
    UpdateById("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME", 1008)
        .primaryKey("id")
        .updateData(mapOf(
            "first_name" to "Tanmay",
        ))
        .returnDocument("before") // return old doc if value 'before'. Supported values are 'before' | 'after'.
        .select("COLUMN_NAMES")
        .upsert(false)
        .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.
Update the customer 1 of the tenant acme
1
2
3
4
5
6
7
let updateById = await g.sys.db.updateById({
    instance: "crm::acme", database: "crm", collection: "customers",
    id: 1,
    updateData: {
        "first_name": "MALLORY"
    }
});
Update the customer 1 of the tenant acme
1
2
3
4
5
6
7
update_by_id = await g.sys.db.update_by_id(
    'crm::acme', 'crm', 'customers',
    1,
    update_data={
        'first_name': 'MALLORY',
    },
)
Update the customer 1 of the tenant acme
1
2
3
4
5
6
7
$updateById = $g->sys->db->updateById(
    'crm::acme', 'crm', 'customers',
    1,
    updateData: [
        'first_name' => 'MALLORY',
    ],
);
Update the customer 1 of the tenant acme
1
2
3
4
5
6
7
var updateById = await g.Sys.Db.UpdateById(new UpdateById("crm::acme", "crm", "customers", 1)
{
    UpdateData = new JsonObject
    {
        ["first_name"] = "MALLORY",
    },
});
Update the customer 1 of the tenant acme
updateById, err := g.Sys.Db.UpdateById(am.UpdateById{
    Instance: "crm::acme", Database: "crm", Collection: "customers",
    Id: 1,
    UpdateData: am.M{
        "first_name": "MALLORY",
    },
})
if err != nil {
    return nil, err
}
Update the customer 1 of the tenant acme
1
2
3
4
5
6
let update_by_id = g.sys.db.update_by_id(
    UpdateById::new("crm::acme", "crm", "customers", json!(1))
        .update_data(json!({
            "first_name": "MALLORY",
        })),
)?;
Update the customer 1 of the tenant acme
1
2
3
4
var updateById = g.sys.db.updateById(new UpdateById("crm::acme", "crm", "customers", 1)
    .updateData(Map.of(
        "first_name", "MALLORY"
    )));
Update the customer 1 of the tenant acme
1
2
3
4
5
6
val updateById = g.sys.db.updateById(
    UpdateById("crm::acme", "crm", "customers", 1)
        .updateData(mapOf(
            "first_name" to "MALLORY",
        )),
)

Without a schema

g.sys.db.gen.updateByIdGen takes the same arguments and calls the update 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.updateByIdGen(…)
Python g.sys.db.gen.update_by_id_gen(…)
PHP $g->sys->db->gen->updateByIdGen(…)
C#, Go g.Sys.Db.Gen.UpdateByIdGen(…)
Rust g.sys.db.update_by_id_gen(UpdateById::new(…))
Java, Kotlin g.sys.db.gen.updateByIdGen(…)