Skip to content

Get indexes

Get indexes System API

List the indexes of a table using global object 'g', in the same format for every database.

1
2
3
4
5
6
7
8
9
const indexes = await g.sys.system.getIndexes({
    instance: 'mysql8',
    database: 'inventory',
    table: 'orders',
});
// [
//     { name: 'PRIMARY', key: { id: 1 }, unique: true },
//     { name: 'am_ix_orders_customer_id_status_3f9a1c', key: { customer_id: 1, status: -1 }, unique: false, method: 'BTREE' },
// ]
  • key holds the fields in order with their direction : 1 ascending, -1 descending, hashed or text on MongoDB.
  • Several tables at once : give a list of such objects, the answer is a list of lists in the same order.
  • instance: "crm::acme" reads the table in the database of the tenant acme of the multi-tenant instance crm.