Skip to content

Get all

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