Code examples
/
Database APIs (g.sys.db)
Array operations
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.arrayOperations calls the array operations 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).
Array operation [push]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation push await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "push" ,
path : "attributes.color" ,
dataToPush : [
"YELLOW" ,
"SKY_BLUE"
]
}
]
});
Array operation push await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'push' ,
'attributes.color' ,
data_to_push = [
'YELLOW' ,
'SKY_BLUE' ,
],
),
],
)
Array operation push $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'push',
'attributes.color',
dataToPush: [
'YELLOW',
'SKY_BLUE',
],
),
],
);
Array operation push await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "push" , "attributes.color" )
{
DataToPush = [
"YELLOW" ,
"SKY_BLUE" ,
],
},
],
});
Array operation push if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "push" ,
Path : "attributes.color" ,
DataToPush : [] any {
"YELLOW" ,
"SKY_BLUE" ,
},
},
},
}); err != nil {
return nil , err
}
Array operation push g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "push" , "attributes.color" )
. data_to_push ([
"YELLOW" ,
"SKY_BLUE" ,
]),
]),
) ? ;
Array operation push g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "push" , "attributes.color" )
. dataToPush (
"YELLOW" ,
"SKY_BLUE"
)
));
Array operation push g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "push" , "attributes.color" )
. dataToPush (
"YELLOW" ,
"SKY_BLUE" ,
),
),
)
Array operation [pull]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation pull await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "pull" ,
path : "ages" ,
queryToRemove : {
"age" : 2 ,
"birth_year" : 1989 ,
"country_id" : 1
}
}
]
});
Array operation pull await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'pull' ,
'ages' ,
query_to_remove = {
'age' : 2 ,
'birth_year' : 1989 ,
'country_id' : 1 ,
},
),
],
)
Array operation pull $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'pull',
'ages',
queryToRemove: [
'age' => 2,
'birth_year' => 1989,
'country_id' => 1,
],
),
],
);
Array operation pull await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "pull" , "ages" )
{
QueryToRemove = new JsonObject
{
["age"] = 2 ,
["birth_year"] = 1989 ,
["country_id"] = 1 ,
},
},
],
});
Array operation pull if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "pull" ,
Path : "ages" ,
QueryToRemove : am . M {
"age" : 2 ,
"birth_year" : 1989 ,
"country_id" : 1 ,
},
},
},
}); err != nil {
return nil , err
}
Array operation pull g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "pull" , "ages" )
. query_to_remove ( json ! ({
"age" : 2 ,
"birth_year" : 1989 ,
"country_id" : 1 ,
})),
]),
) ? ;
Array operation pull g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "pull" , "ages" )
. queryToRemove ( Map . of (
"age" , 2 ,
"birth_year" , 1989 ,
"country_id" , 1
))
));
Array operation pull g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "pull" , "ages" )
. queryToRemove ( mapOf (
"age" to 2 ,
"birth_year" to 1989 ,
"country_id" to 1 ,
)),
),
)
Array operation [pullAll]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation pullAll await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "pullAll" ,
path : "attributes.size" ,
dataToPull : [
3.5
]
}
]
});
Array operation pullAll await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'pullAll' ,
'attributes.size' ,
data_to_pull = [
3.5 ,
],
),
],
)
Array operation pullAll $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'pullAll',
'attributes.size',
dataToPull: [
3.5,
],
),
],
);
Array operation pullAll await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "pullAll" , "attributes.size" )
{
DataToPull = [
3.5 ,
],
},
],
});
Array operation pullAll if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "pullAll" ,
Path : "attributes.size" ,
DataToPull : [] any {
3.5 ,
},
},
},
}); err != nil {
return nil , err
}
Array operation pullAll g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "pullAll" , "attributes.size" )
. data_to_pull ([
json ! ( 3.5 ),
]),
]),
) ? ;
Array operation pullAll g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "pullAll" , "attributes.size" )
. dataToPull (
3.5
)
));
Array operation pullAll g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "pullAll" , "attributes.size" )
. dataToPull (
3.5 ,
),
),
)
Array operation [pop]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation pop await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "pop" ,
path : "attributes.color" ,
direction : 1
}
]
});
Array operation pop await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'pop' ,
'attributes.color' ,
direction = 1 ,
),
],
)
Array operation pop $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'pop',
'attributes.color',
direction: 1,
),
],
);
Array operation pop await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "pop" , "attributes.color" )
{
Direction = 1 ,
},
],
});
Array operation pop if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "pop" ,
Path : "attributes.color" ,
Direction : 1 ,
},
},
}); err != nil {
return nil , err
}
Array operation pop g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "pop" , "attributes.color" )
. direction ( 1 ),
]),
) ? ;
Array operation pop g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "pop" , "attributes.color" )
. direction ( 1 )
));
Array operation pop g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "pop" , "attributes.color" )
. direction ( 1 ),
),
)
Array operation [set]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation set await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "set" ,
dataToSet : {
'ages.birth_year' : 1890 ,
},
arrayFilters : [
{
'item.age' : 4 ,
},
],
}
]
});
Array operation set await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'set' ,
data_to_set = {
'ages.birth_year' : 1890 ,
},
array_filters = [
{
'item.age' : 4 ,
},
],
),
],
)
Array operation set $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'set',
dataToSet: [
'ages.birth_year' => 1890,
],
arrayFilters: [
[
'item.age' => 4,
],
],
),
],
);
Array operation set await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation
{
Operation = "set" ,
DataToSet = new JsonObject
{
["ages.birth_year"] = 1890 ,
},
ArrayFilters = [
new JsonObject
{
["item.age"] = 4 ,
},
],
},
],
});
Array operation set if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "set" ,
DataToSet : am . M {
"ages.birth_year" : 1890 ,
},
ArrayFilters : [] any {
am . M {
"item.age" : 4 ,
},
},
},
},
}); err != nil {
return nil , err
}
Array operation set g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: default ()
. operation ( "set" )
. data_to_set ( json ! ({
"ages.birth_year" : 1890 ,
}))
. array_filters ([
json ! ({
"item.age" : 4 ,
}),
]),
]),
) ? ;
Array operation set g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ()
. operation ( "set" )
. dataToSet ( Map . of (
"ages.birth_year" , 1890
))
. arrayFilters (
Map . of (
"item.age" , 4
)
)
));
Array operation set g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ()
. operation ( "set" )
. dataToSet ( mapOf (
"ages.birth_year" to 1890 ,
))
. arrayFilters (
mapOf (
"item.age" to 4 ,
),
),
),
)
Array operation [addToSet]
TypeScript Python PHP C# Go Rust Java Kotlin
Array operation addToSet await g . sys . db . arrayOperations ({
instance : "mongodb" , database : "inventory" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "addToSet" ,
dataToSet : {
'ages.birth_year' : 1890 ,
},
arrayFilters : [
{
'item.age' : 4 ,
},
],
}
]
});
Array operation addToSet await g . sys . db . array_operations (
'mongodb' , 'inventory' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'addToSet' ,
data_to_set = {
'ages.birth_year' : 1890 ,
},
array_filters = [
{
'item.age' : 4 ,
},
],
),
],
)
Array operation addToSet $g->sys->db->arrayOperations(
'mongodb', 'inventory', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'addToSet',
dataToSet: [
'ages.birth_year' => 1890,
],
arrayFilters: [
[
'item.age' => 4,
],
],
),
],
);
Array operation addToSet await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation
{
Operation = "addToSet" ,
DataToSet = new JsonObject
{
["ages.birth_year"] = 1890 ,
},
ArrayFilters = [
new JsonObject
{
["item.age"] = 4 ,
},
],
},
],
});
Array operation addToSet if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "mongodb" , Database : "inventory" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "addToSet" ,
DataToSet : am . M {
"ages.birth_year" : 1890 ,
},
ArrayFilters : [] any {
am . M {
"item.age" : 4 ,
},
},
},
},
}); err != nil {
return nil , err
}
Array operation addToSet g . sys . db . array_operations (
ArrayOperations :: new ( "mongodb" , "inventory" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: default ()
. operation ( "addToSet" )
. data_to_set ( json ! ({
"ages.birth_year" : 1890 ,
}))
. array_filters ([
json ! ({
"item.age" : 4 ,
}),
]),
]),
) ? ;
Array operation addToSet g . sys . db . arrayOperations ( new ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ()
. operation ( "addToSet" )
. dataToSet ( Map . of (
"ages.birth_year" , 1890
))
. arrayFilters (
Map . of (
"item.age" , 4
)
)
));
Array operation addToSet g . sys . db . arrayOperations (
ArrayOperations ( "mongodb" , "inventory" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ()
. operation ( "addToSet" )
. dataToSet ( mapOf (
"ages.birth_year" to 1890 ,
))
. arrayFilters (
mapOf (
"item.age" to 4 ,
),
),
),
)
Structure
TypeScript Python PHP C# Go Rust Java Kotlin
Array operations await g . sys . db . arrayOperations ({
instance : "INSTANCE_NAME" , database : 'DB_NAME' , collection : "COLLECTION_NAME" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "push" , // push | addToSet | pull | pullAll | pop | set
path : "attributes.color" ,
dataToPush : [
"YELLOW" ,
"SKY_BLUE"
]
},
{
operation : "pull" , // push | addToSet | pull | pullAll | pop | set
path : "attributes.color" ,
dataToPull : [
"SKY_BLUE"
]
}
],
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" ,
},
});
Array operations await g . sys . db . array_operations (
'INSTANCE_NAME' , 'DB_NAME' , 'COLLECTION_NAME' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'push' , # push | addToSet | pull | pullAll | pop | set
'attributes.color' ,
data_to_push = [
'YELLOW' ,
'SKY_BLUE' ,
],
),
ArrayOperation (
'pull' , # push | addToSet | pull | pullAll | pop | set
'attributes.color' ,
data_to_pull = [
'SKY_BLUE' ,
],
),
],
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' ,
},
)
Array operations $g->sys->db->arrayOperations(
'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'push', // push | addToSet | pull | pullAll | pop | set
'attributes.color',
dataToPush: [
'YELLOW',
'SKY_BLUE',
],
),
new ArrayOperation(
'pull', // push | addToSet | pull | pullAll | pop | set
'attributes.color',
dataToPull: [
'SKY_BLUE',
],
),
],
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',
],
);
Array operations await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "push" , "attributes.color" )
{
DataToPush = [
"YELLOW" ,
"SKY_BLUE" ,
],
},
new ArrayOperation ( "pull" , "attributes.color" )
{
DataToPull = [
"SKY_BLUE" ,
],
},
],
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" ,
},
});
Array operations if _ , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "INSTANCE_NAME" , Database : "DB_NAME" , Collection : "COLLECTION_NAME" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "push" , // push | addToSet | pull | pullAll | pop | set
Path : "attributes.color" ,
DataToPush : [] any {
"YELLOW" ,
"SKY_BLUE" ,
},
},
{
Operation : "pull" , // push | addToSet | pull | pullAll | pop | set
Path : "attributes.color" ,
DataToPull : [] any {
"SKY_BLUE" ,
},
},
},
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" ,
},
}); err != nil {
return nil , err
}
Array operations g . sys . db . array_operations (
ArrayOperations :: new ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "push" , "attributes.color" )
. data_to_push ([
"YELLOW" ,
"SKY_BLUE" ,
]),
ArrayOperation :: new ( "pull" , "attributes.color" )
. data_to_pull ([
"SKY_BLUE" ,
]),
])
. 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" ,
})),
) ? ;
Array operations g . sys . db . arrayOperations ( new ArrayOperations ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "push" , "attributes.color" )
. dataToPush (
"YELLOW" ,
"SKY_BLUE"
),
new ArrayOperation ( "pull" , "attributes.color" )
. dataToPull (
"SKY_BLUE"
)
)
. 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"
)));
Array operations g . sys . db . arrayOperations (
ArrayOperations ( "INSTANCE_NAME" , "DB_NAME" , "COLLECTION_NAME" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "push" , "attributes.color" )
. dataToPush (
"YELLOW" ,
"SKY_BLUE" ,
),
ArrayOperation ( "pull" , "attributes.color" )
. dataToPull (
"SKY_BLUE" ,
),
)
. 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.
TypeScript Python PHP C# Go Rust Java Kotlin
Array operations on a customer of the tenant acme let arrayOperations = await g . sys . db . arrayOperations ({
instance : "crm::acme" , database : "crm" , collection : "customers" ,
find : {
"customer_id" : 1
},
operations : [
{
operation : "push" ,
path : "tags" ,
dataToPush : [ "vip" ]
}
]
});
Array operations on a customer of the tenant acme array_operations = await g . sys . db . array_operations (
'crm::acme' , 'crm' , 'customers' ,
find = {
'customer_id' : 1 ,
},
operations = [
ArrayOperation (
'push' ,
'tags' ,
data_to_push = [ 'vip' ],
),
],
)
Array operations on a customer of the tenant acme $arrayOperations = $g->sys->db->arrayOperations(
'crm::acme', 'crm', 'customers',
find: [
'customer_id' => 1,
],
operations: [
new ArrayOperation(
'push',
'tags',
dataToPush: ['vip'],
),
],
);
Array operations on a customer of the tenant acme var arrayOperations = await g . Sys . Db . ArrayOperations ( new ArrayOperations ( "crm::acme" , "crm" , "customers" )
{
Find = new JsonObject
{
["customer_id"] = 1 ,
},
Operations = [
new ArrayOperation ( "push" , "tags" )
{
DataToPush = [ "vip" ],
},
],
});
Array operations on a customer of the tenant acme arrayOperations , err := g . Sys . Db . ArrayOperations ( am . ArrayOperations {
Instance : "crm::acme" , Database : "crm" , Collection : "customers" ,
Find : am . M {
"customer_id" : 1 ,
},
Operations : [] am . ArrayOperation {
{
Operation : "push" ,
Path : "tags" ,
DataToPush : [] any { "vip" },
},
},
})
if err != nil {
return nil , err
}
Array operations on a customer of the tenant acme let array_operations = g . sys . db . array_operations (
ArrayOperations :: new ( "crm::acme" , "crm" , "customers" )
. find ( json ! ({
"customer_id" : 1 ,
}))
. operations ([
ArrayOperation :: new ( "push" , "tags" )
. data_to_push ([ "vip" ]),
]),
) ? ;
Array operations on a customer of the tenant acme var arrayOperations = g . sys . db . arrayOperations ( new ArrayOperations ( "crm::acme" , "crm" , "customers" )
. find ( Map . of (
"customer_id" , 1
))
. operations (
new ArrayOperation ( "push" , "tags" )
. dataToPush ( "vip" )
));
Array operations on a customer of the tenant acme val arrayOperations = g . sys . db . arrayOperations (
ArrayOperations ( "crm::acme" , "crm" , "customers" )
. find ( mapOf (
"customer_id" to 1 ,
))
. operations (
ArrayOperation ( "push" , "tags" )
. dataToPush ( "vip" ),
),
)
Without a schema
g.sys.db.gen.arrayOperationsGen takes the same arguments and calls the array operations 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.arrayOperationsGen(…)
Python
g.sys.db.gen.array_operations_gen(…)
PHP
$g->sys->db->gen->arrayOperationsGen(…)
C#, Go
g.Sys.Db.Gen.ArrayOperationsGen(…)
Rust
g.sys.db.array_operations_gen(ArrayOperations::new(…))
Java, Kotlin
g.sys.db.gen.arrayOperationsGen(…)