Code examples
/
Database APIs (g.sys.db)
Save single or multiple
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.saveSingleOrMultiple calls the save single or multiple 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).
Save single or multiple
TypeScript Python PHP C# Go Rust Java Kotlin
Save single/multiple let saveSingleOrMultiple = await g . sys . db . saveSingleOrMultiple ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
saveData : {
"first_name" : "Bob" ,
"last_name" : "Lin"
}
});
Save single/multiple save_single_or_multiple = await g . sys . db . save_single_or_multiple (
'mysql_8' , 'inventory' , 'customers' ,
{
'first_name' : 'Bob' ,
'last_name' : 'Lin' ,
},
)
Save single/multiple $saveSingleOrMultiple = $g->sys->db->saveSingleOrMultiple(
'mysql_8', 'inventory', 'customers',
[
'first_name' => 'Bob',
'last_name' => 'Lin',
],
);
Save single/multiple var saveSingleOrMultiple = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , new JsonObject
{
["first_name"] = "Bob" ,
["last_name"] = "Lin" ,
}));
Save single/multiple saveSingleOrMultiple , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
SaveData : am . M {
"first_name" : "Bob" ,
"last_name" : "Lin" ,
},
})
if err != nil {
return nil , err
}
Save single/multiple let save_single_or_multiple = g . sys . db . save_single_or_multiple (
Save :: new ( "mysql_8" , "inventory" , "customers" , json ! ({
"first_name" : "Bob" ,
"last_name" : "Lin" ,
})),
) ? ;
Save single/multiple var saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , Map . of (
"first_name" , "Bob" ,
"last_name" , "Lin"
)));
Save single/multiple val saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple (
Save ( "mysql_8" , "inventory" , "customers" , mapOf (
"first_name" to "Bob" ,
"last_name" to "Lin" ,
)),
)
Save single or multiple with multiple data
TypeScript Python PHP C# Go Rust Java Kotlin
Save single/multiple let saveSingleOrMultiple = await g . sys . db . saveSingleOrMultiple ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
saveData : [{
"first_name" : "Bob" ,
"last_name" : "Lin"
},
{
"first_name" : "Alice" ,
"last_name" : "Page"
}]
});
Save single/multiple save_single_or_multiple = await g . sys . db . save_single_or_multiple (
'mysql_8' , 'inventory' , 'customers' ,
[
{
'first_name' : 'Bob' ,
'last_name' : 'Lin' ,
},
{
'first_name' : 'Alice' ,
'last_name' : 'Page' ,
},
],
)
Save single/multiple $saveSingleOrMultiple = $g->sys->db->saveSingleOrMultiple(
'mysql_8', 'inventory', 'customers',
[
[
'first_name' => 'Bob',
'last_name' => 'Lin',
],
[
'first_name' => 'Alice',
'last_name' => 'Page',
],
],
);
Save single/multiple var saveSingleOrMultiple = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , new JsonArray
{
new JsonObject
{
["first_name"] = "Bob" ,
["last_name"] = "Lin" ,
},
new JsonObject
{
["first_name"] = "Alice" ,
["last_name"] = "Page" ,
},
}));
Save single/multiple saveSingleOrMultiple , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
SaveData : [] any {
am . M {
"first_name" : "Bob" ,
"last_name" : "Lin" ,
},
am . M {
"first_name" : "Alice" ,
"last_name" : "Page" ,
},
},
})
if err != nil {
return nil , err
}
Save single/multiple let save_single_or_multiple = g . sys . db . save_single_or_multiple (
Save :: new ( "mysql_8" , "inventory" , "customers" , json ! ([
{
"first_name" : "Bob" ,
"last_name" : "Lin" ,
},
{
"first_name" : "Alice" ,
"last_name" : "Page" ,
},
])),
) ? ;
Save single/multiple var saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , List . of (
Map . of (
"first_name" , "Bob" ,
"last_name" , "Lin"
),
Map . of (
"first_name" , "Alice" ,
"last_name" , "Page"
)
)));
Save single/multiple val saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple (
Save ( "mysql_8" , "inventory" , "customers" , listOf (
mapOf (
"first_name" to "Bob" ,
"last_name" to "Lin" ,
),
mapOf (
"first_name" to "Alice" ,
"last_name" to "Page" ,
),
)),
)
TypeScript Python PHP C# Go Rust Java Kotlin
Save single/multiple with header let saveSingleOrMultiple = await g . sys . db . saveSingleOrMultiple ({
instance : "mysql_8" , database : "inventory" , collection : "customers" ,
saveData : {
"first_name" : "Bob" ,
"last_name" : "Lin"
},
headers : {
"x-am-response-case" : "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
});
Save single/multiple with header save_single_or_multiple = await g . sys . db . save_single_or_multiple (
'mysql_8' , 'inventory' , 'customers' ,
{
'first_name' : 'Bob' ,
'last_name' : 'Lin' ,
},
headers = {
'x-am-response-case' : 'capitalCase' , # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
)
Save single/multiple with header $saveSingleOrMultiple = $g->sys->db->saveSingleOrMultiple(
'mysql_8', 'inventory', 'customers',
[
'first_name' => 'Bob',
'last_name' => 'Lin',
],
headers: [
'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
],
);
Save single/multiple with header var saveSingleOrMultiple = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , new JsonObject
{
["first_name"] = "Bob" ,
["last_name"] = "Lin" ,
})
{
Headers = new JsonObject
{
["x-am-response-case"] = "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
},
});
Save single/multiple with header saveSingleOrMultiple , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "mysql_8" , Database : "inventory" , Collection : "customers" ,
SaveData : am . M {
"first_name" : "Bob" ,
"last_name" : "Lin" ,
},
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
}
Save single/multiple with header let save_single_or_multiple = g . sys . db . save_single_or_multiple (
Save :: new ( "mysql_8" , "inventory" , "customers" , json ! ({
"first_name" : "Bob" ,
"last_name" : "Lin" ,
}))
. headers ( json ! ({
"x-am-response-case" : "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
})),
) ? ;
Save single/multiple with header var saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "customers" , Map . of (
"first_name" , "Bob" ,
"last_name" , "Lin"
))
. headers ( Map . of (
"x-am-response-case" , "capitalCase" // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
)));
Save single/multiple with header val saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple (
Save ( "mysql_8" , "inventory" , "customers" , mapOf (
"first_name" to "Bob" ,
"last_name" to "Lin" ,
))
. headers ( mapOf (
"x-am-response-case" to "capitalCase" , // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
)),
)
Structure
TypeScript Python PHP C# Go Rust Java Kotlin
Save single/multiple structure let saveSingleOrMultiple = await g . sys . db . saveSingleOrMultiple ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
saveData : {
"COLUMN_NAME" : "VALUE" ,
"COLUMN_NAME2" : "VALUE" ,
},
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" ,
},
});
Save single/multiple structure save_single_or_multiple = await g . sys . db . save_single_or_multiple (
'INSTANCE_NAME' , 'DB_NAME' , 'COLLECTION_NAME' ,
{
'COLUMN_NAME' : 'VALUE' ,
'COLUMN_NAME2' : 'VALUE' ,
},
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' ,
},
)
Save single/multiple structure $saveSingleOrMultiple = $g->sys->db->saveSingleOrMultiple(
'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
[
'COLUMN_NAME' => 'VALUE',
'COLUMN_NAME2' => 'VALUE',
],
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',
],
);
Save single/multiple structure var saveSingleOrMultiple = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" , new JsonObject
{
["COLUMN_NAME"] = "VALUE" ,
["COLUMN_NAME2"] = "VALUE" ,
})
{
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" ,
},
});
Save single/multiple structure saveSingleOrMultiple , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "INSTANCE_NAME" , Database : "DB_NAME" , Collection : "COLLECTION_NAME" ,
SaveData : am . M {
"COLUMN_NAME" : "VALUE" ,
"COLUMN_NAME2" : "VALUE" ,
},
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
}
Save single/multiple structure let save_single_or_multiple = g . sys . db . save_single_or_multiple (
Save :: new ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" , json ! ({
"COLUMN_NAME" : "VALUE" ,
"COLUMN_NAME2" : "VALUE" ,
}))
. 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" ,
})),
) ? ;
Save single/multiple structure var saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple ( new Save ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" , Map . of (
"COLUMN_NAME" , "VALUE" ,
"COLUMN_NAME2" , "VALUE"
))
. 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"
)));
Save single/multiple structure val saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple (
Save ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" , mapOf (
"COLUMN_NAME" to "VALUE" ,
"COLUMN_NAME2" to "VALUE" ,
))
. 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
Save a customer of the tenant acme let saveSingleOrMultiple = await g . sys . db . saveSingleOrMultiple ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
saveData : {
"first_name" : "Bob" ,
"last_name" : "Lin"
}
});
Save a customer of the tenant acme save_single_or_multiple = await g . sys . db . save_single_or_multiple (
'crm::acme' , 'crm' , 'customers' ,
{
'first_name' : 'Bob' ,
'last_name' : 'Lin' ,
},
)
Save a customer of the tenant acme $saveSingleOrMultiple = $g->sys->db->saveSingleOrMultiple(
'crm::acme', 'crm', 'customers',
[
'first_name' => 'Bob',
'last_name' => 'Lin',
],
);
Save a customer of the tenant acme var saveSingleOrMultiple = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "crm::acme" , "crm" , "customers" , new JsonObject
{
["first_name"] = "Bob" ,
["last_name"] = "Lin" ,
}));
Save a customer of the tenant acme saveSingleOrMultiple , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "crm::acme" , Database : "crm" , Collection : "customers" ,
SaveData : am . M {
"first_name" : "Bob" ,
"last_name" : "Lin" ,
},
})
if err != nil {
return nil , err
}
Save a customer of the tenant acme let save_single_or_multiple = g . sys . db . save_single_or_multiple (
Save :: new ( "crm::acme" , "crm" , "customers" , json ! ({
"first_name" : "Bob" ,
"last_name" : "Lin" ,
})),
) ? ;
Save a customer of the tenant acme var saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple ( new Save ( "crm::acme" , "crm" , "customers" , Map . of (
"first_name" , "Bob" ,
"last_name" , "Lin"
)));
Save a customer of the tenant acme val saveSingleOrMultiple = g . sys . db . saveSingleOrMultiple (
Save ( "crm::acme" , "crm" , "customers" , mapOf (
"first_name" to "Bob" ,
"last_name" to "Lin" ,
)),
)
Save vectors, JSON and bytes
A vector is a list of numbers, a JSON column takes any object or list, and bytes go as a Buffer object : a plain map in every language. They are read back in the same forms. Data types lists every type of every database.
TypeScript Python PHP C# Go Rust Java Kotlin
Save a vector, JSON and bytes let saved = await g . sys . db . saveSingleOrMultiple ({
instance : "mysql_8" , database : "inventory" , collection : "products" ,
saveData : {
"name" : "Mug" ,
"embedding" : [ 0.12 , 0.5 , 0.33 ],
"details" : { "color" : "blue" , "sizes" : [ 250 , 350 ] },
"photo" : { "type" : "Buffer" , "data" : [ 137 , 80 , 78 , 71 ] }
}
});
Save a vector, JSON and bytes saved = await g . sys . db . save_single_or_multiple (
'mysql_8' , 'inventory' , 'products' ,
{
'name' : 'Mug' ,
'embedding' : [ 0.12 , 0.5 , 0.33 ],
'details' : { 'color' : 'blue' , 'sizes' : [ 250 , 350 ]},
'photo' : { 'type' : 'Buffer' , 'data' : [ 137 , 80 , 78 , 71 ]},
},
)
Save a vector, JSON and bytes $saved = $g->sys->db->saveSingleOrMultiple(
'mysql_8', 'inventory', 'products',
[
'name' => 'Mug',
'embedding' => [0.12, 0.5, 0.33],
'details' => ['color' => 'blue', 'sizes' => [250, 350]],
'photo' => ['type' => 'Buffer', 'data' => [137, 80, 78, 71]],
],
);
Save a vector, JSON and bytes var saved = await g . Sys . Db . SaveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "products" , new JsonObject
{
["name"] = "Mug" ,
["embedding"] = new JsonArray ( 0.12 , 0.5 , 0.33 ),
["details"] = new JsonObject { [ "color" ] = "blue" , [ "sizes" ] = new JsonArray ( 250 , 350 ) },
["photo"] = new JsonObject { [ "type" ] = "Buffer" , [ "data" ] = new JsonArray ( 137 , 80 , 78 , 71 ) },
}));
Save a vector, JSON and bytes saved , err := g . Sys . Db . SaveSingleOrMultiple ( am . Save {
Instance : "mysql_8" , Database : "inventory" , Collection : "products" ,
SaveData : am . M {
"name" : "Mug" ,
"embedding" : [] any { 0.12 , 0.5 , 0.33 },
"details" : am . M { "color" : "blue" , "sizes" : [] any { 250 , 350 }},
"photo" : am . M { "type" : "Buffer" , "data" : [] any { 137 , 80 , 78 , 71 }},
},
})
if err != nil {
return nil , err
}
Save a vector, JSON and bytes let saved = g . sys . db . save_single_or_multiple (
Save :: new ( "mysql_8" , "inventory" , "products" , json ! ({
"name" : "Mug" ,
"embedding" : [ 0.12 , 0.5 , 0.33 ],
"details" : { "color" : "blue" , "sizes" : [ 250 , 350 ] },
"photo" : { "type" : "Buffer" , "data" : [ 137 , 80 , 78 , 71 ] },
})),
) ? ;
Save a vector, JSON and bytes var saved = g . sys . db . saveSingleOrMultiple ( new Save ( "mysql_8" , "inventory" , "products" , Map . of (
"name" , "Mug" ,
"embedding" , List . of ( 0.12 , 0.5 , 0.33 ),
"details" , Map . of ( "color" , "blue" , "sizes" , List . of ( 250 , 350 )),
"photo" , Map . of ( "type" , "Buffer" , "data" , List . of ( 137 , 80 , 78 , 71 ))
)));
Save a vector, JSON and bytes val saved = g . sys . db . saveSingleOrMultiple (
Save ( "mysql_8" , "inventory" , "products" , mapOf (
"name" to "Mug" ,
"embedding" to listOf ( 0.12 , 0.5 , 0.33 ),
"details" to mapOf ( "color" to "blue" , "sizes" to listOf ( 250 , 350 )),
"photo" to mapOf ( "type" to "Buffer" , "data" to listOf ( 137 , 80 , 78 , 71 )),
)),
)
Without a schema
g.sys.db.gen.saveSingleOrMultipleGen takes the same arguments and calls the save single or multiple 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.saveSingleOrMultipleGen(…)
Python
g.sys.db.gen.save_single_or_multiple_gen(…)
PHP
$g->sys->db->gen->saveSingleOrMultipleGen(…)
C#, Go
g.Sys.Db.Gen.SaveSingleOrMultipleGen(…)
Rust
g.sys.db.save_single_or_multiple_gen(Save::new(…))
Java, Kotlin
g.sys.db.gen.saveSingleOrMultipleGen(…)