Skip to content

Get by id

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