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

Get all by stream

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.getAllByStream calls the get all by stream schema API of any table from your code, with the same headers and query parameters as over HTTP. Each row goes to your function as the database sends it, so a large table never sits in memory at once.

Get all using stream API

Get all from table
1
2
3
4
5
6
let response = [];
await g.sys.db.getAllByStream({
    instance: "mysql_8", database: "inventory", collection: "customers",
}, (item) => {
    response.push(item);
});
Get all from table
1
2
3
4
5
6
7
response = []
await g.sys.db.get_all_by_stream(
    GetAll(
        'mysql_8', 'inventory', 'customers',
    ),
    response.append,
)
Get all from table
1
2
3
4
5
6
7
8
9
$response = [];
$g->sys->db->getAllByStream(
    new GetAll(
        'mysql_8', 'inventory', 'customers',
    ),
    function ($item) use (&$response) {
        $response[] = $item;
    },
);
Get all from table
var response = new List<JsonObject>();
await g.Sys.Db.GetAllByStream(new GetAll("mysql_8", "inventory", "customers"), item => response.Add(item));
Get all from table
1
2
3
4
5
6
7
8
9
response := []am.M{}
if err := g.Sys.Db.GetAllByStream(am.GetAll{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
}, func(item am.M) error {
    response = append(response, item)
    return nil
}); err != nil {
    return nil, err
}
Get all from table
1
2
3
4
5
let mut response = Vec::new();
g.sys.db.get_all_by_stream(GetAll::new("mysql_8", "inventory", "customers"), |item| {
    response.push(item.clone());
    Ok(())
})?;
Get all from table
var response = new ArrayList<JsonObject>();
g.sys.db.getAllByStream(new GetAll("mysql_8", "inventory", "customers"), item -> response.add(item));
Get all from table
val response = mutableListOf<JsonObject>()
g.sys.db.getAllByStream(GetAll("mysql_8", "inventory", "customers")) { item -> response.add(item) }

With header

Get all with header
1
2
3
4
5
6
7
8
9
let response = [];
await g.sys.db.getAllByStream({
    instance: "mysql_8", database: "inventory", collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
}, (item) => {
    response.push(item);
});
Get all with header
response = []
await g.sys.db.get_all_by_stream(
    GetAll(
        'mysql_8', 'inventory', 'customers',
        headers={
            'x-am-response-case': 'capitalCase',  # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        },
    ),
    response.append,
)
Get all with header
$response = [];
$g->sys->db->getAllByStream(
    new GetAll(
        'mysql_8', 'inventory', 'customers',
        headers: [
            'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        ],
    ),
    function ($item) use (&$response) {
        $response[] = $item;
    },
);
Get all with header
1
2
3
4
5
6
7
8
var response = new List<JsonObject>();
await g.Sys.Db.GetAllByStream(new GetAll("mysql_8", "inventory", "customers")
{
    Headers = new JsonObject
    {
        ["x-am-response-case"] = "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
}, item => response.Add(item));
Get all with header
response := []am.M{}
if err := g.Sys.Db.GetAllByStream(am.GetAll{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Headers: am.M{
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
}, func(item am.M) error {
    response = append(response, item)
    return nil
}); err != nil {
    return nil, err
}
Get all with header
let mut response = Vec::new();
g.sys.db.get_all_by_stream(
    GetAll::new("mysql_8", "inventory", "customers")
        .headers(json!({
            "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        })),
    |item| {
        response.push(item.clone());
        Ok(())
    },
)?;
Get all with header
1
2
3
4
5
var response = new ArrayList<JsonObject>();
g.sys.db.getAllByStream(new GetAll("mysql_8", "inventory", "customers")
    .headers(Map.of(
        "x-am-response-case", "capitalCase" // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    )), item -> response.add(item));
Get all with header
1
2
3
4
5
6
7
val response = mutableListOf<JsonObject>()
g.sys.db.getAllByStream(
    GetAll("mysql_8", "inventory", "customers")
        .headers(mapOf(
            "x-am-response-case" to "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        )),
) { item -> response.add(item) }

With queryParams

Get all With queryParams
let response = [];
await g.sys.db.getAllByStream({
    instance: "mysql_8", database: "inventory", collection: "customers",
    queryParams: {
        select: "first_name,last_name",
        limit: 10,
        sort: "customer_id",
        find: {
            "first_name": "John"
        },
        skip: 1,
        getTotalCount: true,
        deep: [{
            s_key: "customer_id",
            t_key: "owner_id",
            t_col: "products",
            select: "name, description, price"
        }]
    },
}, (item) => {
    response.push(item);
});
Get all With queryParams
response = []
await g.sys.db.get_all_by_stream(
    GetAll(
        'mysql_8', 'inventory', 'customers',
        select='first_name,last_name',
        limit=10,
        sort='customer_id',
        find={
            'first_name': 'John',
        },
        skip=1,
        get_total_count=True,
        deep=[
            DeepItem(
                'customer_id',
                t_key='owner_id',
                t_col='products',
                select='name, description, price',
            ),
        ],
    ),
    response.append,
)
Get all With queryParams
$response = [];
$g->sys->db->getAllByStream(
    new GetAll(
        'mysql_8', 'inventory', 'customers',
        select: 'first_name,last_name',
        limit: 10,
        sort: 'customer_id',
        find: [
            'first_name' => 'John',
        ],
        skip: 1,
        getTotalCount: true,
        deep: [
            new DeepItem(
                'customer_id',
                tKey: 'owner_id',
                tCol: 'products',
                select: 'name, description, price',
            ),
        ],
    ),
    function ($item) use (&$response) {
        $response[] = $item;
    },
);
Get all With queryParams
var response = new List<JsonObject>();
await g.Sys.Db.GetAllByStream(new GetAll("mysql_8", "inventory", "customers")
{
    Select = "first_name,last_name",
    Limit = 10,
    Sort = "customer_id",
    Find = new JsonObject
    {
        ["first_name"] = "John",
    },
    Skip = 1,
    GetTotalCount = true,
    Deep = new[]
    {
        new DeepItem("customer_id")
        {
            TKey = "owner_id",
            TCol = "products",
            Select = "name, description, price",
        },
    },
}, item => response.Add(item));
Get all With queryParams
response := []am.M{}
if err := g.Sys.Db.GetAllByStream(am.GetAll{
    Instance: "mysql_8", Database: "inventory", Collection: "customers",
    Select: "first_name,last_name",
    Limit:  10,
    Sort:   "customer_id",
    Find: am.M{
        "first_name": "John",
    },
    Skip:          1,
    GetTotalCount: true,
    Deep: []am.DeepItem{
        {
            SKey:   "customer_id",
            TKey:   "owner_id",
            TCol:   "products",
            Select: "name, description, price",
        },
    },
}, func(item am.M) error {
    response = append(response, item)
    return nil
}); err != nil {
    return nil, err
}
Get all With queryParams
let mut response = Vec::new();
g.sys.db.get_all_by_stream(
    GetAll::new("mysql_8", "inventory", "customers")
        .select("first_name,last_name")
        .limit(10)
        .sort("customer_id")
        .find(json!({
            "first_name": "John",
        }))
        .skip(1)
        .get_total_count(true)
        .deep(vec![
            DeepItem::new("customer_id")
                .t_key("owner_id")
                .t_col("products")
                .select("name, description, price"),
        ]),
    |item| {
        response.push(item.clone());
        Ok(())
    },
)?;
Get all With queryParams
var response = new ArrayList<JsonObject>();
g.sys.db.getAllByStream(new GetAll("mysql_8", "inventory", "customers")
    .select("first_name,last_name")
    .limit(10)
    .sort("customer_id")
    .find(Map.of(
        "first_name", "John"
    ))
    .skip(1)
    .getTotalCount(true)
    .deep(List.of(
        new DeepItem("customer_id")
            .tKey("owner_id")
            .tCol("products")
            .select("name, description, price")
    )), item -> response.add(item));
Get all With queryParams
val response = mutableListOf<JsonObject>()
g.sys.db.getAllByStream(
    GetAll("mysql_8", "inventory", "customers")
        .select("first_name,last_name")
        .limit(10)
        .sort("customer_id")
        .find(mapOf(
            "first_name" to "John",
        ))
        .skip(1)
        .getTotalCount(true)
        .deep(listOf(
            DeepItem("customer_id")
                .tKey("owner_id")
                .tCol("products")
                .select("name, description, price"),
        )),
) { item -> response.add(item) }

Structure

Get all by stream with all params
let response = [];
await g.sys.db.getAllByStream({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
    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",
    },
    queryParams: {
        find: {
            "COLUMN_NAME": "COLUMN_VALUE"
        },
        skip: 1,
        limit: 5,
        sort: "COLUMN_NAME",
        select: "COMMA_SEPARATED_COLUMN_NAMES",
        getTotalCount: true,
        deep: [
            {
                s_key: "SOURCE_COLLECTION_COLUMN_NAME",
                t_instance: "TARGET_INSTANCE_NAME",
                t_db: "TARGET_DATABASE_NAME",
                t_col: "TARGET_COLLECTION_NAME",
                t_key: "TARGET_COLLECTION_COLUMN_NAME",
                find: {
                    "COLUMN_NAME": "COLUMN_VALUE"
                },
                isMultiple: true,
                limit: 10,
                select: "COMMA_SEPARATED_COLUMN_NAMES",
                skip: 2,
                sort: "COLUMN_NAME",
                deep: [
                    {
                        s_key: "SOURCE_COLLECTION_COLUMN_NAME",
                        t_instance: "TARGET_INSTANCE_NAME",
                        t_db: "TARGET_DATABASE_NAME",
                        t_col: "TARGET_COLLECTION_NAME",
                        t_key: "TARGET_COLLECTION_COLUMN_NAME",
                        find: {
                            "COLUMN_NAME": "COLUMN_VALUE"
                        },
                        isMultiple: true,
                        limit: 10,
                        select: "COMMA_SEPARATED_COLUMN_NAMES",
                        skip: 2,
                        sort: "COLUMN_NAME",
                    }
                ]
            }
        ]
    },
}, (item) => {
    response.push(item);
});
Get all by stream with all params
response = []
await g.sys.db.get_all_by_stream(
    GetAll(
        'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
        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',
        },
        find={
            'COLUMN_NAME': 'COLUMN_VALUE',
        },
        skip=1,
        limit=5,
        sort='COLUMN_NAME',
        select='COMMA_SEPARATED_COLUMN_NAMES',
        get_total_count=True,
        deep=[
            DeepItem(
                'SOURCE_COLLECTION_COLUMN_NAME',
                t_instance='TARGET_INSTANCE_NAME',
                t_db='TARGET_DATABASE_NAME',
                t_col='TARGET_COLLECTION_NAME',
                t_key='TARGET_COLLECTION_COLUMN_NAME',
                find={
                    'COLUMN_NAME': 'COLUMN_VALUE',
                },
                is_multiple=True,
                limit=10,
                select='COMMA_SEPARATED_COLUMN_NAMES',
                skip=2,
                sort='COLUMN_NAME',
                deep=[
                    DeepItem(
                        'SOURCE_COLLECTION_COLUMN_NAME',
                        t_instance='TARGET_INSTANCE_NAME',
                        t_db='TARGET_DATABASE_NAME',
                        t_col='TARGET_COLLECTION_NAME',
                        t_key='TARGET_COLLECTION_COLUMN_NAME',
                        find={
                            'COLUMN_NAME': 'COLUMN_VALUE',
                        },
                        is_multiple=True,
                        limit=10,
                        select='COMMA_SEPARATED_COLUMN_NAMES',
                        skip=2,
                        sort='COLUMN_NAME',
                    ),
                ],
            ),
        ],
    ),
    response.append,
)
Get all by stream with all params
$response = [];
$g->sys->db->getAllByStream(
    new GetAll(
        'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
        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',
        ],
        find: [
            'COLUMN_NAME' => 'COLUMN_VALUE',
        ],
        skip: 1,
        limit: 5,
        sort: 'COLUMN_NAME',
        select: 'COMMA_SEPARATED_COLUMN_NAMES',
        getTotalCount: true,
        deep: [
            new DeepItem(
                'SOURCE_COLLECTION_COLUMN_NAME',
                tInstance: 'TARGET_INSTANCE_NAME',
                tDb: 'TARGET_DATABASE_NAME',
                tCol: 'TARGET_COLLECTION_NAME',
                tKey: 'TARGET_COLLECTION_COLUMN_NAME',
                find: [
                    'COLUMN_NAME' => 'COLUMN_VALUE',
                ],
                isMultiple: true,
                limit: 10,
                select: 'COMMA_SEPARATED_COLUMN_NAMES',
                skip: 2,
                sort: 'COLUMN_NAME',
                deep: [
                    new DeepItem(
                        'SOURCE_COLLECTION_COLUMN_NAME',
                        tInstance: 'TARGET_INSTANCE_NAME',
                        tDb: 'TARGET_DATABASE_NAME',
                        tCol: 'TARGET_COLLECTION_NAME',
                        tKey: 'TARGET_COLLECTION_COLUMN_NAME',
                        find: [
                            'COLUMN_NAME' => 'COLUMN_VALUE',
                        ],
                        isMultiple: true,
                        limit: 10,
                        select: 'COMMA_SEPARATED_COLUMN_NAMES',
                        skip: 2,
                        sort: 'COLUMN_NAME',
                    ),
                ],
            ),
        ],
    ),
    function ($item) use (&$response) {
        $response[] = $item;
    },
);
Get all by stream with all params
var response = new List<JsonObject>();
await g.Sys.Db.GetAllByStream(new GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
{
    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",
    },
    Find = new JsonObject
    {
        ["COLUMN_NAME"] = "COLUMN_VALUE",
    },
    Skip = 1,
    Limit = 5,
    Sort = "COLUMN_NAME",
    Select = "COMMA_SEPARATED_COLUMN_NAMES",
    GetTotalCount = true,
    Deep = new[]
    {
        new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
        {
            TInstance = "TARGET_INSTANCE_NAME",
            TDb = "TARGET_DATABASE_NAME",
            TCol = "TARGET_COLLECTION_NAME",
            TKey = "TARGET_COLLECTION_COLUMN_NAME",
            Find = new JsonObject
            {
                ["COLUMN_NAME"] = "COLUMN_VALUE",
            },
            IsMultiple = true,
            Limit = 10,
            Select = "COMMA_SEPARATED_COLUMN_NAMES",
            Skip = 2,
            Sort = "COLUMN_NAME",
            Deep = new[]
            {
                new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
                {
                    TInstance = "TARGET_INSTANCE_NAME",
                    TDb = "TARGET_DATABASE_NAME",
                    TCol = "TARGET_COLLECTION_NAME",
                    TKey = "TARGET_COLLECTION_COLUMN_NAME",
                    Find = new JsonObject
                    {
                        ["COLUMN_NAME"] = "COLUMN_VALUE",
                    },
                    IsMultiple = true,
                    Limit = 10,
                    Select = "COMMA_SEPARATED_COLUMN_NAMES",
                    Skip = 2,
                    Sort = "COLUMN_NAME",
                },
            },
        },
    },
}, item => response.Add(item));
Get all by stream with all params
response := []am.M{}
if err := g.Sys.Db.GetAllByStream(am.GetAll{
    Instance: "INSTANCE_NAME", Database: "DB_NAME", Collection: "COLLECTION_NAME",
    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",
    },
    Find: am.M{
        "COLUMN_NAME": "COLUMN_VALUE",
    },
    Skip:          1,
    Limit:         5,
    Sort:          "COLUMN_NAME",
    Select:        "COMMA_SEPARATED_COLUMN_NAMES",
    GetTotalCount: true,
    Deep: []am.DeepItem{
        {
            SKey:      "SOURCE_COLLECTION_COLUMN_NAME",
            TInstance: "TARGET_INSTANCE_NAME",
            TDb:       "TARGET_DATABASE_NAME",
            TCol:      "TARGET_COLLECTION_NAME",
            TKey:      "TARGET_COLLECTION_COLUMN_NAME",
            Find: am.M{
                "COLUMN_NAME": "COLUMN_VALUE",
            },
            IsMultiple: true,
            Limit:      10,
            Select:     "COMMA_SEPARATED_COLUMN_NAMES",
            Skip:       2,
            Sort:       "COLUMN_NAME",
            Deep: []am.DeepItem{
                {
                    SKey:      "SOURCE_COLLECTION_COLUMN_NAME",
                    TInstance: "TARGET_INSTANCE_NAME",
                    TDb:       "TARGET_DATABASE_NAME",
                    TCol:      "TARGET_COLLECTION_NAME",
                    TKey:      "TARGET_COLLECTION_COLUMN_NAME",
                    Find: am.M{
                        "COLUMN_NAME": "COLUMN_VALUE",
                    },
                    IsMultiple: true,
                    Limit:      10,
                    Select:     "COMMA_SEPARATED_COLUMN_NAMES",
                    Skip:       2,
                    Sort:       "COLUMN_NAME",
                },
            },
        },
    },
}, func(item am.M) error {
    response = append(response, item)
    return nil
}); err != nil {
    return nil, err
}
Get all by stream with all params
let mut response = Vec::new();
g.sys.db.get_all_by_stream(
    GetAll::new("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .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",
        }))
        .find(json!({
            "COLUMN_NAME": "COLUMN_VALUE",
        }))
        .skip(1)
        .limit(5)
        .sort("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .get_total_count(true)
        .deep(vec![
            DeepItem::new("SOURCE_COLLECTION_COLUMN_NAME")
                .t_instance("TARGET_INSTANCE_NAME")
                .t_db("TARGET_DATABASE_NAME")
                .t_col("TARGET_COLLECTION_NAME")
                .t_key("TARGET_COLLECTION_COLUMN_NAME")
                .find(json!({
                    "COLUMN_NAME": "COLUMN_VALUE",
                }))
                .is_multiple(true)
                .limit(10)
                .select("COMMA_SEPARATED_COLUMN_NAMES")
                .skip(2)
                .sort("COLUMN_NAME")
                .deep(vec![
                    DeepItem::new("SOURCE_COLLECTION_COLUMN_NAME")
                        .t_instance("TARGET_INSTANCE_NAME")
                        .t_db("TARGET_DATABASE_NAME")
                        .t_col("TARGET_COLLECTION_NAME")
                        .t_key("TARGET_COLLECTION_COLUMN_NAME")
                        .find(json!({
                            "COLUMN_NAME": "COLUMN_VALUE",
                        }))
                        .is_multiple(true)
                        .limit(10)
                        .select("COMMA_SEPARATED_COLUMN_NAMES")
                        .skip(2)
                        .sort("COLUMN_NAME"),
                ]),
        ]),
    |item| {
        response.push(item.clone());
        Ok(())
    },
)?;
Get all by stream with all params
var response = new ArrayList<JsonObject>();
g.sys.db.getAllByStream(new GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
    .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"
    ))
    .find(Map.of(
        "COLUMN_NAME", "COLUMN_VALUE"
    ))
    .skip(1)
    .limit(5)
    .sort("COLUMN_NAME")
    .select("COMMA_SEPARATED_COLUMN_NAMES")
    .getTotalCount(true)
    .deep(List.of(
        new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
            .tInstance("TARGET_INSTANCE_NAME")
            .tDb("TARGET_DATABASE_NAME")
            .tCol("TARGET_COLLECTION_NAME")
            .tKey("TARGET_COLLECTION_COLUMN_NAME")
            .find(Map.of(
                "COLUMN_NAME", "COLUMN_VALUE"
            ))
            .isMultiple(true)
            .limit(10)
            .select("COMMA_SEPARATED_COLUMN_NAMES")
            .skip(2)
            .sort("COLUMN_NAME")
            .deep(List.of(
                new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
                    .tInstance("TARGET_INSTANCE_NAME")
                    .tDb("TARGET_DATABASE_NAME")
                    .tCol("TARGET_COLLECTION_NAME")
                    .tKey("TARGET_COLLECTION_COLUMN_NAME")
                    .find(Map.of(
                        "COLUMN_NAME", "COLUMN_VALUE"
                    ))
                    .isMultiple(true)
                    .limit(10)
                    .select("COMMA_SEPARATED_COLUMN_NAMES")
                    .skip(2)
                    .sort("COLUMN_NAME")
            ))
    )), item -> response.add(item));
Get all by stream with all params
val response = mutableListOf<JsonObject>()
g.sys.db.getAllByStream(
    GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .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",
        ))
        .find(mapOf(
            "COLUMN_NAME" to "COLUMN_VALUE",
        ))
        .skip(1)
        .limit(5)
        .sort("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .getTotalCount(true)
        .deep(listOf(
            DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
                .tInstance("TARGET_INSTANCE_NAME")
                .tDb("TARGET_DATABASE_NAME")
                .tCol("TARGET_COLLECTION_NAME")
                .tKey("TARGET_COLLECTION_COLUMN_NAME")
                .find(mapOf(
                    "COLUMN_NAME" to "COLUMN_VALUE",
                ))
                .isMultiple(true)
                .limit(10)
                .select("COMMA_SEPARATED_COLUMN_NAMES")
                .skip(2)
                .sort("COLUMN_NAME")
                .deep(listOf(
                    DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
                        .tInstance("TARGET_INSTANCE_NAME")
                        .tDb("TARGET_DATABASE_NAME")
                        .tCol("TARGET_COLLECTION_NAME")
                        .tKey("TARGET_COLLECTION_COLUMN_NAME")
                        .find(mapOf(
                            "COLUMN_NAME" to "COLUMN_VALUE",
                        ))
                        .isMultiple(true)
                        .limit(10)
                        .select("COMMA_SEPARATED_COLUMN_NAMES")
                        .skip(2)
                        .sort("COLUMN_NAME"),
                )),
        )),
) { item -> response.add(item) }

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.
Get all customers of the tenant acme by stream
1
2
3
4
5
6
let response = [];
await g.sys.db.getAllByStream({
    instance: "crm::acme", database: "crm", collection: "customers",
}, (item) => {
    response.push(item);
});
Get all customers of the tenant acme by stream
1
2
3
4
5
6
7
response = []
await g.sys.db.get_all_by_stream(
    GetAll(
        'crm::acme', 'crm', 'customers',
    ),
    response.append,
)
Get all customers of the tenant acme by stream
1
2
3
4
5
6
7
8
9
$response = [];
$g->sys->db->getAllByStream(
    new GetAll(
        'crm::acme', 'crm', 'customers',
    ),
    function ($item) use (&$response) {
        $response[] = $item;
    },
);
Get all customers of the tenant acme by stream
var response = new List<JsonObject>();
await g.Sys.Db.GetAllByStream(new GetAll("crm::acme", "crm", "customers"), item => response.Add(item));
Get all customers of the tenant acme by stream
1
2
3
4
5
6
7
8
9
response := []am.M{}
if err := g.Sys.Db.GetAllByStream(am.GetAll{
    Instance: "crm::acme", Database: "crm", Collection: "customers",
}, func(item am.M) error {
    response = append(response, item)
    return nil
}); err != nil {
    return nil, err
}
Get all customers of the tenant acme by stream
1
2
3
4
5
let mut response = Vec::new();
g.sys.db.get_all_by_stream(GetAll::new("crm::acme", "crm", "customers"), |item| {
    response.push(item.clone());
    Ok(())
})?;
Get all customers of the tenant acme by stream
var response = new ArrayList<JsonObject>();
g.sys.db.getAllByStream(new GetAll("crm::acme", "crm", "customers"), item -> response.add(item));
Get all customers of the tenant acme by stream
val response = mutableListOf<JsonObject>()
g.sys.db.getAllByStream(GetAll("crm::acme", "crm", "customers")) { item -> response.add(item) }

Without a schema

g.sys.db.gen.getAllByStreamGen takes the same arguments and calls the get all by stream 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.getAllByStreamGen(…)
Python g.sys.db.gen.get_all_by_stream_gen(…)
PHP $g->sys->db->gen->getAllByStreamGen(…)
C#, Go g.Sys.Db.Gen.GetAllByStreamGen(…)
Rust g.sys.db.get_all_by_stream_gen(GetAll::new(…))
Java, Kotlin g.sys.db.gen.getAllByStreamGen(…)