Skip to content

Query for get data by stream

Structure

Query by stream
let response = [];
await g.sys.db.gen.queryByStreamGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    find: {
        "pincode": 100050
    },
    limit: 1,
    select: "COLUMN_NAMES",
    deep: [{
        s_key: "SOURCE_COLLECTION_COLUMN_NAME",
        t_key: "TARGET_COLLECTION_COLUMN_NAME",
        t_col: "TARGET_COLLECTION_NAME",
        select: "COLUMN_NAMES"
    }],
    skip: 1,
    sort: "COLUMN_NAME",
    groupBy: "COLUMN_NAME"
}, (obj) => {
    response.push(obj);
});

Simple queryByStream

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

Simple [headers]

headers
let response = [];
await g.sys.db.gen.queryByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Bob"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
}, (obj) => {
    response.push(obj);
});

Simple [select]

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

Simple [limit]

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

Simple [skip]

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

Simple [sort]

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

Simple [deep]

deep
let response = [];
await g.sys.db.gen.queryByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Bob"
    },
    deep: [
        {
            s_key: "customer_id",
            t_col: "products",
            t_key: "owner_id",
            select: "customer_id,first_name"
        }
    ]
}, (obj) => {
    response.push(obj);
});

$lt queryByStream

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

$lte queryByStream

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

$gt queryByStream

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

$gte queryByStream

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

$eq queryByStream

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

$ne queryByStream

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

$not queryByStream

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

$and queryByStream

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

$or queryByStream

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

$in queryByStream

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

$nin queryByStream

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

$like queryByStream

$like queryByStream
let response = [];
await g.sys.db.gen.queryByStreamGen({
    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.gen.queryByStreamGen({
    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.gen.queryByStreamGen({
    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.gen.queryByStreamGen({
    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.gen.queryByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "eventListeners.versions.name": "Original"
            },
            {
                "eventListeners.versions.version": "-1"
            }
        ]
    }
}, (obj) => {
    response.push(obj);
});