Skip to content

Distinct

Structure

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

Simple distinct

Simple distinct
1
2
3
4
5
6
let distinct = await g.sys.db.gen.distinctGen({
    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.distinctGen({
    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.distinctGen({
    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.distinctGen({
    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.distinctGen({
    instance: "mysql_8",
    database: "inventory",
    collection: "customers",
    distinctField: "first_name",
    headers: {
        "x-am-response-case": "capitalCase"
    },
    order: "asc"
});

Multi-tenant

  • instance: "crm::acme" works on the database of the tenant acme of the multi-tenant instance crm.
  • With instance: "crm", the call works on the database of the tenant of the request: a custom API called with the x-am-tenant-username header passes it on to the APIs it calls. A request without a tenant works on the structure database.
Distinct first names of the customers of the tenant acme
1
2
3
4
let distinct = await g.sys.db.gen.distinctGen({
    instance: "crm::acme", database: "crm", collection: "customers",
    distinctField: "first_name"
});