Code examples
/
Database APIs (g.sys.db)
Replace 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.replaceById calls the replace 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).
Replace By Id
TypeScript Python PHP C# Go Rust Java Kotlin
Replace By Id let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : 1 ,
updateData : {
"first_name" : "MALLORY"
}
});
Replace By Id replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
1 ,
update_data = {
'first_name' : 'MALLORY' ,
},
)
Replace By Id $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
1,
updateData: [
'first_name' => 'MALLORY',
],
);
Replace By Id var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 1 )
{
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
},
});
Replace By Id replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : 1 ,
UpdateData : am . M {
"first_name" : "MALLORY" ,
},
})
if err != nil {
return nil , err
}
Replace By Id let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , json ! ( 1 ))
. update_data ( json ! ({
"first_name" : "MALLORY" ,
})),
) ? ;
Replace By Id var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 1 )
. updateData ( Map . of (
"first_name" , "MALLORY"
)));
Replace By Id val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , 1 )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
)),
)
Replace By Id [primaryKey] override
TypeScript Python PHP C# Go Rust Java Kotlin
Replace By Id primary key override let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : "Bob" ,
primaryKey : "first_name" ,
updateData : {
"first_name" : "MALLORY"
}
});
Replace By Id primary key override replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
'Bob' ,
primary_key = 'first_name' ,
update_data = {
'first_name' : 'MALLORY' ,
},
)
Replace By Id primary key override $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
'Bob',
primaryKey: 'first_name',
updateData: [
'first_name' => 'MALLORY',
],
);
Replace By Id primary key override var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , "Bob" )
{
PrimaryKey = "first_name" ,
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
},
});
Replace By Id primary key override replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : "Bob" ,
PrimaryKey : "first_name" ,
UpdateData : am . M {
"first_name" : "MALLORY" ,
},
})
if err != nil {
return nil , err
}
Replace By Id primary key override let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , "Bob" )
. primary_key ( "first_name" )
. update_data ( json ! ({
"first_name" : "MALLORY" ,
})),
) ? ;
Replace By Id primary key override var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , "Bob" )
. primaryKey ( "first_name" )
. updateData ( Map . of (
"first_name" , "MALLORY"
)));
Replace By Id primary key override val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , "Bob" )
. primaryKey ( "first_name" )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
)),
)
TypeScript Python PHP C# Go Rust Java Kotlin
Replace By Id header let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : 606 ,
updateData : {
"first_name" : "MALLORY"
},
headers : {
"x-am-response-case" : "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
});
Replace By Id header replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
606 ,
update_data = {
'first_name' : 'MALLORY' ,
},
headers = {
'x-am-response-case' : 'capitalCase' , # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
)
Replace By Id header $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
606,
updateData: [
'first_name' => 'MALLORY',
],
headers: [
'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
],
);
Replace By Id header var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 606 )
{
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
},
Headers = new JsonObject
{
["x-am-response-case"] = "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
});
Replace By Id header replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : 606 ,
UpdateData : am . M {
"first_name" : "MALLORY" ,
},
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
}
Replace By Id header let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , json ! ( 606 ))
. update_data ( json ! ({
"first_name" : "MALLORY" ,
}))
. headers ( json ! ({
"x-am-response-case" : "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
})),
) ? ;
Replace By Id header var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 606 )
. updateData ( Map . of (
"first_name" , "MALLORY"
))
. headers ( Map . of (
"x-am-response-case" , "capitalCase" // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
)));
Replace By Id header val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , 606 )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
))
. headers ( mapOf (
"x-am-response-case" to "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
)),
)
Replace By Id [upsert]
TypeScript Python PHP C# Go Rust Java Kotlin
Replace By Id upsert let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : 505 ,
updateData : {
"first_name" : "MALLORY"
},
upsert : true
});
Replace By Id upsert replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
505 ,
update_data = {
'first_name' : 'MALLORY' ,
},
upsert = True ,
)
Replace By Id upsert $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
505,
updateData: [
'first_name' => 'MALLORY',
],
upsert: true,
);
Replace By Id upsert var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 505 )
{
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
},
Upsert = true ,
});
Replace By Id upsert replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : 505 ,
UpdateData : am . M {
"first_name" : "MALLORY" ,
},
Upsert : true ,
})
if err != nil {
return nil , err
}
Replace By Id upsert let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , json ! ( 505 ))
. update_data ( json ! ({
"first_name" : "MALLORY" ,
}))
. upsert ( true ),
) ? ;
Replace By Id upsert var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 505 )
. updateData ( Map . of (
"first_name" , "MALLORY"
))
. upsert ( true ));
Replace By Id upsert val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , 505 )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
))
. upsert ( true ),
)
Replace By Id [returnDocument]
TypeScript Python PHP C# Go Rust Java Kotlin
Replace By Id returnDocument let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : 80 ,
updateData : {
"first_name" : "MALLORY"
},
returnDocument : 'before' , // return old doc if value 'before'. Supported values are 'before' | 'after'.
});
Replace By Id returnDocument replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
80 ,
update_data = {
'first_name' : 'MALLORY' ,
},
return_document = 'before' , # return old doc if value 'before'. Supported values are 'before' | 'after'.
)
Replace By Id returnDocument $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
80,
updateData: [
'first_name' => 'MALLORY',
],
returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
);
Replace By Id returnDocument var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 80 )
{
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
},
ReturnDocument = "before" , // return old doc if value 'before'. Supported values are 'before' | 'after'.
});
Replace By Id returnDocument replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : 80 ,
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
}
Replace By Id returnDocument let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , json ! ( 80 ))
. update_data ( json ! ({
"first_name" : "MALLORY" ,
}))
. return_document ( "before" ), // return old doc if value 'before'. Supported values are 'before' | 'after'.
) ? ;
Replace By Id returnDocument var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 80 )
. updateData ( Map . of (
"first_name" , "MALLORY"
))
. returnDocument ( "before" )); // return old doc if value 'before'. Supported values are 'before' | 'after'.
Replace By Id returnDocument val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , 80 )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
))
. returnDocument ( "before" ), // return old doc if value 'before'. Supported values are 'before' | 'after'.
)
Structure
TypeScript Python PHP C# Go Rust Java Kotlin
Replace by id with all params let replaceById = await g . sys . db . replaceById ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
id : 45855 ,
primaryKey : "pincode" ,
updateData : {
"first_name" : "Elonn" ,
"last_name" : "Mask"
},
returnDocument : 'before' , // return old doc if value 'before'. Supported values are 'before' | 'after'.
select : "COMMA_SEPARATED_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" ,
},
});
Replace by id with all params replace_by_id = await g . sys . db . replace_by_id (
'mysql_8' , 'inventory' , 'customers' ,
45855 ,
primary_key = 'pincode' ,
update_data = {
'first_name' : 'Elonn' ,
'last_name' : 'Mask' ,
},
return_document = 'before' , # return old doc if value 'before'. Supported values are 'before' | 'after'.
select = 'COMMA_SEPARATED_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' ,
},
)
Replace by id with all params $replaceById = $g->sys->db->replaceById(
'mysql_8', 'inventory', 'customers',
45855,
primaryKey: 'pincode',
updateData: [
'first_name' => 'Elonn',
'last_name' => 'Mask',
],
returnDocument: 'before', // return old doc if value 'before'. Supported values are 'before' | 'after'.
select: 'COMMA_SEPARATED_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',
],
);
Replace by id with all params var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 45855 )
{
PrimaryKey = "pincode" ,
UpdateData = new JsonObject
{
["first_name"] = "Elonn" ,
["last_name"] = "Mask" ,
},
ReturnDocument = "before" , // return old doc if value 'before'. Supported values are 'before' | 'after'.
Select = "COMMA_SEPARATED_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" ,
},
});
Replace by id with all params replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
Id : 45855 ,
PrimaryKey : "pincode" ,
UpdateData : am . M {
"first_name" : "Elonn" ,
"last_name" : "Mask" ,
},
ReturnDocument : "before" , // return old doc if value 'before'. Supported values are 'before' | 'after'.
Select : "COMMA_SEPARATED_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
}
Replace by id with all params let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "mysql_8" , "inventory" , "customers" , json ! ( 45855 ))
. primary_key ( "pincode" )
. update_data ( json ! ({
"first_name" : "Elonn" ,
"last_name" : "Mask" ,
}))
. return_document ( "before" ) // return old doc if value 'before'. Supported values are 'before' | 'after'.
. select ( "COMMA_SEPARATED_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" ,
})),
) ? ;
Replace by id with all params var replaceById = g . sys . db . replaceById ( new UpdateById ( "mysql_8" , "inventory" , "customers" , 45855 )
. primaryKey ( "pincode" )
. updateData ( Map . of (
"first_name" , "Elonn" ,
"last_name" , "Mask"
))
. returnDocument ( "before" ) // return old doc if value 'before'. Supported values are 'before' | 'after'.
. select ( "COMMA_SEPARATED_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"
)));
Replace by id with all params val replaceById = g . sys . db . replaceById (
UpdateById ( "mysql_8" , "inventory" , "customers" , 45855 )
. primaryKey ( "pincode" )
. updateData ( mapOf (
"first_name" to "Elonn" ,
"last_name" to "Mask" ,
))
. returnDocument ( "before" ) // return old doc if value 'before'. Supported values are 'before' | 'after'.
. select ( "COMMA_SEPARATED_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.
TypeScript Python PHP C# Go Rust Java Kotlin
Replace the customer 1 of the tenant acme let replaceById = await g . sys . db . replaceById ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
id : 1 ,
updateData : {
"first_name" : "MALLORY" ,
"last_name" : "Lin"
}
});
Replace the customer 1 of the tenant acme replace_by_id = await g . sys . db . replace_by_id (
'crm::acme' , 'crm' , 'customers' ,
1 ,
update_data = {
'first_name' : 'MALLORY' ,
'last_name' : 'Lin' ,
},
)
Replace the customer 1 of the tenant acme $replaceById = $g->sys->db->replaceById(
'crm::acme', 'crm', 'customers',
1,
updateData: [
'first_name' => 'MALLORY',
'last_name' => 'Lin',
],
);
Replace the customer 1 of the tenant acme var replaceById = await g . Sys . Db . ReplaceById ( new UpdateById ( "crm::acme" , "crm" , "customers" , 1 )
{
UpdateData = new JsonObject
{
["first_name"] = "MALLORY" ,
["last_name"] = "Lin" ,
},
});
Replace the customer 1 of the tenant acme replaceById , err := g . Sys . Db . ReplaceById ( am . UpdateById {
Instance : "crm::acme" , Database : "crm" , Collection : "customers" ,
Id : 1 ,
UpdateData : am . M {
"first_name" : "MALLORY" ,
"last_name" : "Lin" ,
},
})
if err != nil {
return nil , err
}
Replace the customer 1 of the tenant acme let replace_by_id = g . sys . db . replace_by_id (
UpdateById :: new ( "crm::acme" , "crm" , "customers" , json ! ( 1 ))
. update_data ( json ! ({
"first_name" : "MALLORY" ,
"last_name" : "Lin" ,
})),
) ? ;
Replace the customer 1 of the tenant acme var replaceById = g . sys . db . replaceById ( new UpdateById ( "crm::acme" , "crm" , "customers" , 1 )
. updateData ( Map . of (
"first_name" , "MALLORY" ,
"last_name" , "Lin"
)));
Replace the customer 1 of the tenant acme val replaceById = g . sys . db . replaceById (
UpdateById ( "crm::acme" , "crm" , "customers" , 1 )
. updateData ( mapOf (
"first_name" to "MALLORY" ,
"last_name" to "Lin" ,
)),
)
Without a schema
g.sys.db.gen.replaceByIdGen takes the same arguments and calls the replace 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.replaceByIdGen(…)
Python
g.sys.db.gen.replace_by_id_gen(…)
PHP
$g->sys->db->gen->replaceByIdGen(…)
C#, Go
g.Sys.Db.Gen.ReplaceByIdGen(…)
Rust
g.sys.db.replace_by_id_gen(UpdateById::new(…))
Java, Kotlin
g.sys.db.gen.replaceByIdGen(…)