Skip to content

Query for get data by stream

Simple query by stream

Simple query by stream to get data
let response = await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
}, (obj) => {
    response.push(obj);
});

query by stream [headers]

query by stream headers
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
}, (obj) => {
    response.push(obj);
});

query by stream [select]

query by stream select
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    select: "first_name"
}, (obj) => {
    response.push(obj);
});

query by stream [limit]

query by stream limit
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    limit: 2
}, (obj) => {
    response.push(obj);
});

query by stream[skip]

query by stream skip
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    skip: 1
}, (obj) => {
    response.push(obj);
});

query by stream [sort]

query by stream sort
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    sort: "first_name"
}, (obj) => {
    response.push(obj);
});

query by stream [deep]

query by stream deep
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    deep: [
        {
            s_key: "customer_id",
            t_instance: "mysql",
            t_db: "inventory",
            t_col: "products",
            t_key: "owner_id",
        }
    ],
}, (obj) => {
    response.push(obj);
});

$lt [less than] query

less than query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lt": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$lte [less than equal] query

less than equal query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lte": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$gt [greater than] query

greater than query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gt": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$gte [greater than equal] query

greater than equal query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gte": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$eq [equal to] query

$eq query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$eq": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$ne [not equal to] query

$ne query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$ne": 2
        }
    }
}, (obj) => {
    response.push(obj);
});

$not [not] query

$not query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$not": {
                "$in": [1, 2, 3, 4]
            }
        }
    }
}, (obj) => {
    response.push(obj);
});

$and [and] query

$and query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$and": [
            {
                "customer_id": 2
            },
            {
                "zipcode": 7171
            }
        ]
    }
}, (obj) => {
    response.push(obj);
});

$or [or] query

$or query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "customer_id": 2
            },
            {
                "zipcode": 7171
            }
        ]
    }
}, (obj) => {
    response.push(obj);
});

$in [in] query

$in query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$in": [1, 2]
        }
    }
}, (obj) => {
    response.push(obj);
});

$nin [not in] query

$nin query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$nin": [1, 2]
        }
    }
}, (obj) => {
    response.push(obj);
});

$like [like] query

$like query
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$like": "Bob%"
        }
    }
}, (obj) => {
    response.push(obj);
});

MongoDB $in operator in nested find

$in operator in nested find
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "eventListeners.versions.name": {
            "$in": [
                "Original",
                "1"
            ]
        }
    }
}, (obj) => {
    response.push(obj);
});

MongoDB $nin operator in nested find

$nin operator in nested find
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "eventListeners.versions.name": {
            "$nin": [
                "Original",
                "1"
            ]
        }
    }
}, (obj) => {
    response.push(obj);
});

MongoDB $and operator in nested find

$and operator in nested find
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$and": [
            {
                "eventListeners.versions.name": "Original"
            },
            {
                "eventListeners.versions.version": "-1"
            }
        ]
    }
}, (obj) => {
    response.push(obj);
});

MongoDB $or operator in nested find

$or operator in nested find
let response = [];
await g.sys.db.queryByStream({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "eventListeners.versions.name": "Original"
            },
            {
                "eventListeners.versions.version": "-1"
            }
        ]
    }
}, (obj) => {
    response.push(obj);
});

Structure

query by stream with all params
let response = [];
await g.sys.db.queryByStream({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    find: {
        "COLUMN_NAME": "VALUE"
    },
    limit: 10,
    select: "COMMA_SEPARATED_COLUMN_NAMES",
    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",
        }
    ],
    skip: 1,
    sort: "COLUMN_NAME",
    groupBy: "COLUMN_NAME",
    updateData: {
        "COLUMN_NAME": "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-secret": "PROVIDE_SECRET_ID",
        "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
        // 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",
    },
}, (obj) => {
    response.push(obj);
});