Skip to content

Count

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