Skip to content

Generate APIs

Structure

Structure
let getAll = await g.sys.db.gen.getAllGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    queryParams: {
        deep: JSON.stringify([{
            s_key: "SOURCE_COLLECTION_COLUMN_NAME",
            t_key: "TARGET_COLLECTION_COLUMN_NAME",
            t_col: "TARGET_COLLECTION_NAME",
            select: "COLUMN_NAMES"
        }]),
        select: "COLUMN_NAMES",
        limit: 2,
        sort: "COLUMN_NAME"
    }
});

Simple Get all with one condition

Simple Get all from table
let getAll = await g.sys.db.gen.getAllGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    queryParams: {
        find: {
            first_name: 'James'
        }
    }
});

With header

Get all with header
1
2
3
4
5
6
7
8
let getAll = await g.sys.db.gen.getAllGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

With header and queryParams

Get all with header and queryParams
let getAll = await g.sys.db.gen.getAllGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-meta": "true"
    },
    queryParams: {
        select: "first_name,last_name"
    }
});

With multiple queryParams

Get all with multiple queryParams
let getAll = await g.sys.db.gen.getAllGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    queryParams: {
        select: "first_name,last_name",
        limit: 2
    }
});

With all params

Get all with all params
let getAll = await g.sys.db.gen.getAllGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    queryParams: {
        select: "first_name,last_name",
        limit: 1,
        sort: "customer_id",
        deep: [{
            s_key: "customer_id",
            t_key: "owner_id",
            t_col: "products",
            select: "proName,proDescription,proPrice"
        }]
    }
});

Structure

Get all by stream
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    queryParams: {
        deep: `[{
            s_key: "SOURCE_COLLECTION_COLUMN_NAME",
            t_key: "TARGET_COLLECTION_COLUMN_NAME",
            t_col: "TARGET_COLLECTION_NAME",
            select: "COLUMN_NAMES"  
        }]`,
        select: "COLUMN_NAMES",
        sort: "-COLUMN_NAME",
        limit: 2,
        find: `{"price": 42187}`,
        skip: 1,
    }
}, (item) => {
    response.push(item);
});

Simple Get all

Simple Get all from table
1
2
3
4
5
6
7
8
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
}, (item) => {
    response.push(item);
});

With header

Get all with header
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    }
}, (item) => {
    response.push(item);
});

With header and queryParams

Get all with header and queryParams
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    queryParams: {
        select: "first_name,last_name"
    }
}, (item) => {
    response.push(item);
});

With multiple queryParams

Get all With multiple queryParams
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    queryParams: {
        select: "first_name,last_name",
        limit: 2
    }
}, (item) => {
    response.push(item);
});

With all params

Get all With all params
let response = [];
await g.sys.db.gen.getAllByStreamGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    queryParams: {
        select: "first_name,last_name",
        limit: 1,
        sort: "customer_id",
    }
}, (item) => {
    response.push(item);
});

Structure

Get by id
1
2
3
4
5
6
7
8
let getById = await g.sys.db.gen.getByIdGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    id: 100050,
    primaryKey: 'COLUMN_NAME'
    select: "COLUMN_NAMES"
});

Simple Get by id

Simple Get by id from table
1
2
3
4
5
6
let getById = await g.sys.db.gen.getByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 2
});

With header

Get by id with header
1
2
3
4
5
6
7
8
9
let getById = await g.sys.db.gen.getByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 2,
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

With header and select

Get by id with header and select
let getById = await g.sys.db.gen.getByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 2,
    headers: {
        "x-am-response-case": "capitalCase"
    },
    select:"first_name,last_name"
});

With primary key override

Get by id with primary key override
1
2
3
4
5
6
7
let getById= await g.sys.db.gen.getByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "NICK",
    primaryKey:"first_name",
});

With all params

Get by id with all params
let getAll = await g.sys.db.gen.getByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "NICK",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    select: "first_name,last_name",
    deep: [{ // string, string[], array of objects are supported
        s_key: "customer_id",
        t_key: "owner_id",
        t_col: "products",
        select: "proName,proDescription,proPrice"
    }],
    primaryKey: "first_name"
});

Structure

Save single/multiple structure
1
2
3
4
5
6
7
8
9
let saveSingleOrMultiple = await g.sys.db.gen.saveSingleOrMultipleGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    saveData: {
        "field1": "fieldValue1",
        "field2": "fieldValue2"
    }
});

Save single or multiple

Save single/multiple
1
2
3
4
5
6
7
8
9
let saveSingleOrMultiple = await g.sys.db.gen.saveSingleOrMultipleGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: {
        "first_name": "Bob",
        "last_name": "Lin"
    }
});

Save single or multiple with multiple data

Save single/multiple
let saveSingleOrMultiple = await g.sys.db.gen.saveSingleOrMultipleGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: [{
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }]
});

with header

Save single/multiple with header
let saveSingleOrMultiple = await g.sys.db.gen.saveSingleOrMultipleGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

Structure

Master save
1
2
3
4
5
6
7
8
9
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    saveData: {
        first_name: "James",
        last_name: "Bond"
    }
});

master save single data

Master save
1
2
3
4
5
6
7
8
9
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: {
        "first_name": "Bob",
        "last_name": "Lin"
    }
});

master save multiple data

Master save
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: [
        {
            "first_name": "Bob",
            "last_name": "Lin"
        },
        {
            "first_name": "Bob",
            "last_name": "Lin"
        }
    ]
});

with header

Master save with header
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

multiple database entry

Master save with multy data[with help of schema configuration]
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: {
        "city_name": "Wembley", //city_name save in mysql database
        "state_id": {
            "state_name": "London", //state_name save in maria database
            "country_id": {
                "country_name":"UK" //country_name save in postGreSql database
            }
        }
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

multiple database multiple entry entry

Master save with multy data[with help of schema configuration]
let masterSave = await g.sys.db.gen.masterSaveGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    saveData: [{
        "city_name": "Wembley",
        "state_id": {
            "state_name": "London",
            "country_id": 302
        }
    },
    {
        "city_name": "Buffalo",
        "state_id": {
            "state_name": "Chicago",
            "country_id": 303
        }
    }],
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

Schema-less Array Operations API

Array operations
await g.sys.db.gen.arrayOperationsGen({
    instance: 'INSTANCE_NAME',
    database: 'DATABASE_NAME',
    collection: 'COLLECTION_NAME',
    find: {
        "id": 1
    },
    operations: [
        {
            operation: "push",
            path: "attributes.color",
            dataToPush: [
                "YELLOW",
                "SKY_BLUE"
            ]
        }
    ]
});
Array operations headers support
1
2
3
4
5
6
await g.sys.db.gen.arrayOperationsGen({
    // ...
    headers: {
        "x-am-authorization": "TOKEN"
    }
});

Structure

Update by id
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    id: 1008,
    primaryKey: "id",
    updateData: {
        "first_name": "Tanmay",
        "last_name": "Samay"
    },
    returnOriginal: true,
    select: "COLUMN_NAMES",
    upsert: false
});

Simple updateById

Update By Id
1
2
3
4
5
6
7
8
9
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 1,
    updateData: {
        "first_name": "MALLORY"
    }
});

updateById primaryKey override

Update By Id primarykey override
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    }
});

updateById [select]

Update By Id with select
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name"
});

updateById [headers]

Update By Id with select
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name",
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

updateById [upsert]

Update By Id with upsert
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    upsert: true
});

updateById [returnDocument]

Update By Id with upsert
let updateById = await g.sys.db.gen.updateByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Alice",
    primaryKey: "first_name",
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    returnDocument: true 
});

Structure

Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    find: {
        "id": {
            "$in": [1018, 1019]
        }
    },
    updateData: {
        "city_name": "DELHI"
    }
});

Simple update-many

Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Alice"
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

update-many with header

Update many with header
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Alice"
    },
    updateData: {
        "first_name": "MALLORY"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

$in update-many

$in Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$in": [2, 3]
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$nin update-many

$nin Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$nin": [2, 3]
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$and update-many

$and Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        $and: [
            {
                "first_name": "Alice"
            },
            {
                "isActive": 1
            }
        ]
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$or update-many

$or Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        $or: [
            {
                "first_name": "Alice"
            },
            {
                "isActive": 1
            }
        ]
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$eq update-many

$eq Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$eq": 2
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$gt update-many

$gt Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$gt": 2
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$gte update-many

$gte Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$gte": 2
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$lt update-many

$lt Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$lt": 2
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

$lte update-many

$lte Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$lte": 2
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

[mongoDB] update-many

$mongoDB Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": 2,
        "ages.birth_year": "1889"
    },
    updateData: {
        "ages.$.age": "35"
    }
});

[MongoDB] $elemMatch, $gte, $lte update-many

$elemMatch, $gte, $lte Update many
let updateMany = await g.sys.db.gen.updateManyGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": 2,
        "ages": {
            "$elemMatch": {
                "age": {
                    "$gte": 30
                },
                "birth_year": {
                    "$lte": 1900
                }
            }
        }
    },
    updateData: {
        "first_name": "MALLORY"
    }
});

Structure

Replace by id
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    id: 45855,
    primaryKey: "pincode",
    updateData: {
        "first_name": "Elonn",
        "last_name": "Mask"
    },
    returnOriginal: true,
    select: "COLUMN_NAMES",
    upsert: false
});

Simple replaceById

Replace By Id
1
2
3
4
5
6
7
8
9
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 1,
    updateData: {
        "first_name": "MALLORY"
    }
});

replaceById primaryKey override

Replace By Id primarykey override
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    }
});

replaceById [header]

Replace By Id header
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

replaceById [select]

Replace By Id select
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name"
});

replaceById [upsert]

Replace By Id upsert
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name",
    upsert: true
});

replaceById [returnDocument]

Replace By Id returnDocument
let replaceById = await g.sys.db.gen.replaceByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name",
    returnDocument: true
});

Structure

Remove by id
1
2
3
4
5
6
7
8
let removeById = await g.sys.db.gen.removeByIdGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    select: "COLUMN_NAMES",
    id: 7878,
    primaryKey: "COLUMN_NAME"
});

Simple removeById

Remove By Id
1
2
3
4
5
6
7
8
9
let updateById = await g.sys.db.gen.removeByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: 1,
    updateData: {
        "first_name": "MALLORY"
    }
});

removeById primaryKey override

Remove By Id primarykey override
let updateById = await g.sys.db.gen.removeByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    }
});

removeById [header]

Remove By Id header
let updateById = await g.sys.db.gen.removeByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

removeById [select]

Remove By Id header
let updateById = await g.sys.db.gen.removeByIdGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    id: "Bob",
    primaryKey: "first_name",    
    updateData: {
        "first_name": "MALLORY"
    },
    select: "first_name,last_name"
});

Structure

Remove by query
1
2
3
4
5
6
7
8
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    find: {
        "city_name": "LONDON"
    }
});

Simple removeByQuery

Remove by query
1
2
3
4
5
6
7
8
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Bob"
    }
});

$lt removeByQuery

$lt Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lt": 2
        }
    }
});

$lte removeByQuery

$lte Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lte": 2
        }
    }
});

$gt removeByQuery

$gt Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gt": 2
        }
    }
});

$gte removeByQuery

$gte Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gte": 2
        }
    }
});

$eq removeByQuery

$eq Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$eq": 2
        }
    }
});

$ne removeByQuery

$ne Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$ne": 2
        }
    }
});

$not removeByQuery

$not Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$not": {
                "$in": [1, 2, 3, 4]
            }
        }
    }
});

$and removeByQuery

$and Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$and": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});

$or removeByQuery

$or Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});

$in removeByQuery

$in Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$in": [1, 2]
        }
    }
});

$nin removeByQuery

$nin Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "customer_id": {
            "$nin": [1, 2]
        }
    }
});

$like removeByQuery

$nin Remove by query
let updateById = await g.sys.db.gen.removeByQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$like": "Bob%"
        }
    }
});

MongoDB $in operator in nested find

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

MongoDB $nin operator in nested find

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

MongoDB $and operator in nested find

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

MongoDB $or operator in nested find

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


##Structure
```typescript title="Query method" linenums="1"
let query = await g.sys.db.gen.queryGen({
    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"
});

Simple query

Simple query
1
2
3
4
5
6
7
8
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    }
});

Simple [headers]

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

Simple [select]

select
1
2
3
4
5
6
7
8
9
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    select: "first_name"
});

Simple [limit]

limit
1
2
3
4
5
6
7
8
9
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    limit: 2
});

Simple [skip]

skip
1
2
3
4
5
6
7
8
9
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    skip: 1
});

Simple [sort]

sort
1
2
3
4
5
6
7
8
9
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    },
    sort: "first_name"
});

Simple [deep]

deep
let query = await g.sys.db.gen.queryGen({
    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"
        }
    ]
});

$lt query

$lt query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lt": 2
        }
    }
});

$lte query

$lte query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$lte": 2
        }
    }
});

$gt query

$gt query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gt": 2
        }
    }
});

$gte query

$gte query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$gte": 2
        }
    }
});

$eq query

$eq query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$eq": 2
        }
    }
});

$ne query

$ne query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        customer_id: {
            "$ne": 2
        }
    }
});

$not query

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

$and query

$and query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$and": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});

$or query

$or query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});

$in query

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

$nin query

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

$like query

$like query
let query = await g.sys.db.gen.queryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$like": "Bob%"
        }
    }
});

MongoDB $in operator in nested find

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

MongoDB $nin operator in nested find

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

MongoDB $and operator in nested find

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

MongoDB $or operator in nested find

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

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);
});

Structure

Aggregate method
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    aggregateQuery: [
        {
            "$match":
                {
                    "first_name": "JENNIFER"
                }
        }
    ]
});

MongoDB Simple aggregate

MongoDB Simple aggregate
1
2
3
4
5
6
7
8
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[{
        "$limit": 2
    }]
});

MongoDB headers

MongoDB headers
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[{
        "$limit": 2
    }],
    headers: {
        "x-am-authorization": "TOKEN"
    }
});

MongoDB Basic aggregation

MongoDB Basic aggregation
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[[
        {
            "$group": {
                "_id": "$_id",
                "total": {
                    "$sum": "$customer_id"
                }
            }
        },
        {
            "$match": {
                "total": {
                    "$gt": 1
                }
            }
        },
        {
            "$sort": {
                "total": -1
            }
        },
        {
            "$count": "CountValue"
        }
    ]]
});

MongoDB $project stage

MongoDB $project stage
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "full_name": {
                    "$toLower": "$first_name"
                }
            }
        }
    ]
});

MongoDB $addFields

MongoDB $addFields
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$addFields": {
                "full_name": {
                    "$concat": [
                        "$first_name",
                        " ",
                        "$last_name"
                    ]
                }
            }
        }
    ]
});

MongoDB $bucket

MongoDB $bucket
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$bucket": {
                "groupBy": "$price",
                "boundaries": [10000,20000,30000,40000,50000],
                "default": "Other",
                "output": {
                    "count": {
                        "$sum": 1
                    },
                    "product_details": {
                        "$push": {
                            "name": "$name",
                            "price": "$price"
                        }
                    }
                }
            }
        }
    ]
});

MongoDB $facet with multiple $bucket

MongoDB $facet with multiple $bucket
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$facet": {
                "price": [
                    {
                        "$bucket": {
                            "groupBy": "$price",
                            "boundaries": [10000,20000,30000,40000,50000,60000,70000,80000],
                            "default": "Other",
                            "output": {
                                "count": {
                                    "$sum": 1
                                },
                                "product_details": {
                                    "$push": {
                                        "name": "$name",
                                        "price": "$price"
                                    }
                                }
                            }
                        }
                    }
                ],
                "categories": [
                    {
                        "$bucket": {
                            "groupBy": "$category_id",
                            "boundaries": [10000,20000,30000,40000,50000,60000,70000,80000],
                            "default": "Other",
                            "output": {
                                "count": {
                                    "$sum": 1
                                },
                                "product_details": {
                                    "$push": {
                                        "name": "$name",
                                        "id": "$id",
                                        "category_id": "$category_id"
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    ]
});

MongoDB $collStats, latencyStats > histograms, storageStats, count

MongoDB $collStats, latencyStats > histograms, storageStats, count
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$collStats": {
                "latencyStats": {
                    "histograms": true
                },
                "storageStats": {},
                "count": {}
            }
        }
    ]
});

MongoDB $collStats, latencyStats > histograms, storageStats, count

MongoDB $collStats, latencyStats > histograms, storageStats, count
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$collStats": {
                "latencyStats": {
                    "histograms": true
                },
                "storageStats": {},
                "count": {}
            }
        }
    ]
});

MongoDB $count

MongoDB $count
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$match": {
                "price": {
                    "$gt": 10000
                }
            }
        },
        {
            "$count": "price_gt_10000"
        }
    ]
});

MongoDB $limit

MongoDB $limit
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$limit": 2
        }
    ]
});

MongoDB $lookup

MongoDB $lookup
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$lookup": {
                "from": "products",
                "localField": "customer_id",
                "foreignField": "owner_id",
                "as": "customer_data"
            }
        }
    ]
});

MongoDB $match

MongoDB $match
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$match": {
                "first_name": "Bob"
            }
        }
    ]
});

MongoDB $redact, $cond, if, then, else, $$DESCEND, $$PRUNE

MongoDB $redact, $cond, if, then, else, $$DESCEND, $$PRUNE
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$redact": {
                "$cond": {
                    "if": {
                        "$eq": [
                            "$first_name",
                            "JOHNNY"
                        ]
                    },
                    "then": "$$DESCEND",
                    "else": "$$PRUNE"
                }
            }
        }
    ]
});

MongoDB $replaceRoot, newRoot

MongoDB $replaceRoot, newRoot
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$replaceRoot": {
                "newRoot": {
                    "full_name": {
                        "$concat": [
                            "$first_name",
                            " ",
                            "$last_name"
                        ]
                    }
                }
            }
        }
    ]
});

MongoDB $sample

MongoDB $sample
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$sample": {
                "size": 2
            }
        }
    ]
});

MongoDB $skip

MongoDB $skip
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$skip": 2
        }
    ]
});

MongoDB $sort

ascending

MongoDB $sort
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$sort": {
                "customer_id": 1
            }
        }
    ]
});

descending

MongoDB $sort
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$sort": {
                "customer_id": -1
            }
        }
    ]
});

MongoDB $unwind, $sortByCount

MongoDB $unwind, $sortByCount
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$unwind": "$ages"
        },
        {
            "$sortByCount": "$ages"
        }
    ]
});

MongoDB $abs, $subtract

MongoDB $abs, $subtract
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "Grand_Total": {
                    "$abs": {
                        "$subtract": [
                            "$total",
                            "$tax"
                        ]
                    }
                }
            }
        }
    ]
});

MongoDB $add

MongoDB $add
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "Grand_Total": {
                    "$add": [
                        "$price",
                        "$category_id"
                    ]
                }
            }
        }
    ]
});

MongoDB $ceil, $floor

MongoDB $ceil, $floor
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "ceilingValue": {
                    "$ceil": "$price"
                },
                "floorValue": {
                    "$floor": "$price"
                },
                "id": 1
            }
        }
    ]
});

MongoDB $divide

MongoDB $divide
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "pricePercentage": {
                    "$divide": [
                        "$price",
                        100
                    ]
                },
                "id": 1
            }
        }
    ]
});

MongoDB $multiply

MongoDB $multiply
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "Grand_Total": {
                    "$multiply": [
                        "$price",
                        "$quantity"
                    ]
                },
                "id": 1
            }
        }
    ]
});

MongoDB $arrayElemAt

MongoDB $arrayElemAt
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
          "$project": {
            "first": {
              "$arrayElemAt": [
                "$attribuites.color",
                1
              ]
            }
          }
        }
    ]
});

MongoDB $filter

MongoDB $filter
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
          "$project": {
            "ages": {
              "$filter": {
                "input": "$ages",
                "as": "age",
                "cond": {
                  "$gte": [
                    "$$age.age",
                    50
                  ]
                }
              }
            }
          }
        }
    ]
});

MongoDB $in

MongoDB $in
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "customer_id": "$customer_id",
                "TravelingHobby": {
                    "$in": [
                        "traveling",
                        "$hobbies"
                    ]
                }
            }
        }
    ]
});

MongoDB $indexOfArray

MongoDB $indexOfArray
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "customer_id": "$customer_id",
                "index": {
                    "$indexOfArray": [
                        "$ages.birth_year",
                        1971
                    ]
                }
            }
        }
    ]
});

MongoDB $isArray

MongoDB $isArray
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "isHobbyCricket": {
                    "$cond": {
                        "if": {
                            "$isArray": "$hobbies"
                        },
                        "then": {
                            "$in": [
                                "traveling",
                                "$hobbies"
                            ]
                        },
                        "else": "One or more fields is not an array."
                    }
                }
            }
        }
    ]
});

MongoDB $map

MongoDB $map
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "integerValues": {
                    "$map": {
                        "input": "$distances",
                        "as": "decimalValue",
                        "in": {
                            "$trunc": "$$decimalValue"
                        }
                    }
                }
            }
        }
    ]
});

MongoDB $reverseArray

MongoDB $reverseArray
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "reverseDistances": {
                    "$reverseArray": "$distances"
                }
            }
        }
    ]
});

MongoDB $size

MongoDB $size
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "customer_id": 1,
                "address": 1,
                "numberOfHobbies": {
                    "$cond": {
                        "if": {
                            "$isArray": "$hobbies"
                        },
                        "then": {
                            "$size": "$hobbies"
                        },
                        "else": "NA"
                    }
                }
            }
        }
    ]
});

MongoDB $and

MongoDB $and
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": "$id",
                "result": {
                    "$and": [
                        {
                            "$gt": [
                                "$price",
                                60000
                            ]
                        },
                        {
                            "$lt": [
                                "$category_id",
                                45000
                            ]
                        }
                    ]
                }
            }
        }
    ]
});

MongoDB $not

MongoDB $not
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": "$id",
                "result": {
                    "$not": [
                        {
                            "$gt": [
                                "$price",
                                30000
                            ]
                        }
                    ]
                }
            }
        }
    ]
});

MongoDB $or

MongoDB $or
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": "$id",
                "result": {
                    "$or": [
                        {
                            "$gt": [
                                "$price",
                                60000
                            ]
                        },
                        {
                            "$lt": [
                                "$category_id",
                                1000
                            ]
                        }
                    ]
                }
            }
        }
    ]
});

MongoDB $cmp

MongoDB $cmp
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "comparePrice": {
                    "$cmp": [
                        "$price",
                        42187
                    ]
                },
                "_id": 1
            }
        }
    ]
});

MongoDB $eq

MongoDB $eq
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "equalPrice": {
                    "$eq": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $gt

MongoDB $gt
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "graterPrice": {
                    "$gt": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $gte

MongoDB $gte
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "gePrice": {
                    "$gte": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $lt

MongoDB $lt
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "graterPrice": {
                    "$lt": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $lte

MongoDB $lte
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "gePrice": {
                    "$lte": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $ne

MongoDB $ne
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "nePrice": {
                    "$ne": [
                        "$price",
                        42187
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $cond

MongoDB $cond
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "price": 1,
                "discount": {
                    "$cond": {
                        "if": {
                            "$gt": [
                                "$price",
                                50000
                            ]
                        },
                        "then": 30,
                        "else": 10
                    }
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $ifNull

MongoDB $ifNull
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "price": 1,
                "shipping": {
                    "$ifNull": [
                        "$shipping",
                        null
                    ]
                },
                "_id": 0
            }
        }
    ]
});

MongoDB $switch

MongoDB $switch
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "price": 1,
                "priceSummary": {
                    "$switch": {
                        "branches": [
                            {
                                "case": {
                                    "$eq": [
                                        "$price",
                                        50000
                                    ]
                                },
                                "then": "equals"
                            },
                            {
                                "case": {
                                    "$gt": [
                                        "$price",
                                        50000
                                    ]
                                },
                                "then": "greater than"
                            },
                            {
                                "case": {
                                    "$lt": [
                                        "$price",
                                        50000
                                    ]
                                },
                                "then": "less than"
                            }
                        ]
                    }
                }
            }
        }
    ]
});

MongoDB $concat

MongoDB $concat
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$project": {
                "id": 1,
                "name_Description": {
                    "$concat": [
                        "$name",
                        "_",
                        "$description"
                    ]
                }
            }
        }
    ]
});

MongoDB $max

MongoDB $max
let aggregate = await g.sys.db.gen.aggregateGen({
    instance: "mongodb",
    database: "inventory",
    collection: "customers",
    aggregateQuery:[
        {
            "$group": {
                "_id": "$price",
                "maxQuantity": {
                    "$max": "$quantity"
                }
            }
        }
    ]
});

Structure

Count method
1
2
3
4
5
6
7
8
let count = await g.sys.db.gen.countGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    find: {
        "pincode": 100050
    }
});

Simple get count

Simple get count
1
2
3
4
5
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers"
});

Simple headers

Simple headers
1
2
3
4
5
6
7
8
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

Simple find

Simple find
1
2
3
4
5
6
7
8
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find:{
        "first_name": "Bob"
    }
});

$gt

$gt
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$gt": 4
        }
    }
});

$gte

$gte
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$gte": 4
        }
    }
});

$lt

$lt
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$lt": 4
        }
    }
});

$lte

$lte
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$lte": 4
        }
    }
});

$eq

$eq
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$eq": "Bob"
        }
    }
});

$ne

$ne
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$ne": "Bob"
        }
    }
});

$in

$in
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$in": [1, 2]
        }
    }
});

$nin

$nin
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive": {
            "$nin": [1, 2]
        }
    }
});

$and

$and
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$and": [
            {
                "employee_Details.emp_Id": 1
            },
            {
                "city": "Baroda"
            }
        ]
    }
});

$or

$or
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "$or": [
            {
                "employee_Details.emp_Id": 1
            },
            {
                "city": "Baroda"
            }
        ]
    }
});

$like

$like
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$like": "%Mall%"
        }
    }
});

% after text

% after text
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": {
            "$like": "Mall%"
        }
    }
});

count with multiple column

count with multiple column
1
2
3
4
5
6
7
8
9
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Mallory",
        "last_name": "Brown"
    }
});

count with multiple column

count with multiple column
1
2
3
4
5
6
7
8
9
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "first_name": "Mallory",
        "last_name": "Brown"
    }
});

floating value support

floating value support
let count = await g.sys.db.gen.countGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    find: {
        "isActive":{
            "$gt": 2.2
        }
    }
});

Structure

Distinct method
1
2
3
4
5
6
7
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    distinctField: "COLUMN_NAME",
    order: "asc"n
});

Simple distinct

Simple distinct
1
2
3
4
5
6
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name"
});

distinct with header

distinct with header
1
2
3
4
5
6
7
8
9
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

distinct with order

ascending

distinct with order
1
2
3
4
5
6
7
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    order: "asc"
});

descending

distinct with header
1
2
3
4
5
6
7
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    order: "desc"
});

distinct with headers and order

distinct with header & order
let distinct = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    order: "asc"
});

Structure

Distinct Query
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "INSTANCE_NAME",
    database: "DATABASE_NAME",
    collection: "COLLECTION_NAME",
    distinctField: "COLUMN_NAME",
    order: "asc",
    find: {
        "price": 42187
    }
});

Simple get distinctWithQuery

Simple distinctWithQuery
1
2
3
4
5
6
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name"
});

distinctWithQuery with multiple distinctField

distinctWithQuery with multiple distinctField
1
2
3
4
5
6
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name,last_name"
});

distinctWithQuery with headers

distinctWithQuery with headers
1
2
3
4
5
6
7
8
9
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    headers: {
        "x-am-response-case": "capitalCase"
    }
});

distinctWithQuery with order

ascending

distinctWithQuery with ascending order
1
2
3
4
5
6
7
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    order: "asc"
});

descending

distinctWithQuery with descending order
1
2
3
4
5
6
7
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    order: "desc"
});

distinctWithQuery with headers and order

distinctWithQuery with headers
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    order: "asc"
});

distinctWithQuery with find

distinctWithQuery with find
1
2
3
4
5
6
7
8
9
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        first_name: "Bob"
    }
});

$lt distinctWithQuery

distinctWithQuery with $lt
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$lt": 2
        }
    }
});

$lte distinctWithQuery

distinctWithQuery with $lte
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$lte": 2
        }
    }
});

$gt distinctWithQuery

distinctWithQuery with $gt
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$gt": 2
        }
    }
});

$gte distinctWithQuery

distinctWithQuery with $gte
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$gte": 2
        }
    }
});

$eq distinctWithQuery

distinctWithQuery with $eq
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$eq": 2
        }
    }
});

$ne distinctWithQuery

distinctWithQuery with $ne
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$ne": 2
        }
    }
});

$not distinctWithQuery

distinctWithQuery with $not
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$not": {
                "$in": [1,2,3]
            }
        }
    }
});

$and distinctWithQuery

distinctWithQuery with $and
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        "$and": [
            {
                "customer_id": 1
            },
            {
                "pincode": 382345
            }
        ]
    }
});

$or distinctWithQuery

distinctWithQuery with $or
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        "$or": [
            {
                "customer_id": 1
            },
            {
                "pincode": 382345
            }
        ]
    }
});

$in distinctWithQuery

distinctWithQuery with $in
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$in": [1, 2,3]
        }
    }
});

$nin distinctWithQuery

distinctWithQuery with $nin
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        customer_id: {
            "$nin": [1, 2,3]
        }
    }
});

$like distinctWithQuery

distinctWithQuery with $like
let distinctQuery = await g.sys.db.gen.distinctQueryGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    find: {
        first_name: {
            "$like": "Bob%"
        }
    }
});