Skip to content

Distinct with query

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