Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Get all

Reads the rows of a table. With query params, it is the list API of your screens : filter, sort, pages, columns, related rows.

In short

  • GET /api/schema/<user-path>/<instance>/<database>/<table>
  • Without limit, it returns every row that matches.
  • It takes every query param : find, a column, skip, limit, sort, select, deep, getTotalCount.
Method GET
URL /api/schema/admin/mysql8/inventory/customers
Body none
Query params find, a column, skip, limit, sort, select, deep, getTotalCount
Answer data : a list of rows. totalCount with getTotalCount=true.
Databases MongoDB, MySQL, MariaDB, PostgreSQL, SQL Server, Oracle, TiDB, Percona
Cached yes, when enableCaching is on for the table or the database
From code g.sys.db.getAll
API id SCHEMA_GET_ALL
Without a schema /api/gen/admin/mysql8/inventory/customers : below

The URL

Put your own names in /api/schema/admin/mysql8/inventory/customers : the user path of your account (admin), the instance (mysql8), the database (inventory) and the table (customers). The examples read this table :

customer_id first_name last_name last_update pincode isActive
1 Bob Lin 2022-11-14 04:34:58 382345 1
2 Alice Page 2022-10-15 02:10:40 382346 1
3 Mallory Brown 2022-09-13 03:44:05 382347 1
4 Eve Mathly 2022-11-12 01:59:33 382348 1
5 Eve Page 2022-11-12 01:59:33 382349 1

Every row

GET /api/schema/admin/mysql8/inventory/customers
{
    "success": true,
    "statusCode": 200,
    "data": [
        { "customer_id": 1, "first_name": "Bob", "last_name": "Lin", "last_update": "2022-11-14T04:34:58.000Z", "pincode": 382345, "isActive": 1 },
        { "customer_id": 2, "first_name": "Alice", "last_name": "Page", "last_update": "2022-10-15T02:10:40.000Z", "pincode": 382346, "isActive": 1 }
    ]
}

A page of a list

Page 2 of the active customers : 2 rows a page, in the order of their id, two columns, and the total for the pager.

GET /api/schema/admin/mysql8/inventory/customers?find={isActive:1}&sort=customer_id&skip=2&limit=2&select=first_name,last_name&getTotalCount=true
{
    "success": true,
    "statusCode": 200,
    "data": [
        { "customer_id": 3, "first_name": "Mallory", "last_name": "Brown" },
        { "customer_id": 4, "first_name": "Eve", "last_name": "Mathly" }
    ],
    "totalCount": 5
}

Short filters

A column name in the URL filters too :

GET /api/schema/admin/mysql8/inventory/customers?first_name=Bob,Alice
GET /api/schema/admin/mysql8/inventory/customers?pincode>=382346

See A column as a query param for every form.

deep puts the related rows in the answer. Here, the orders of each customer :

GET /api/schema/admin/mysql8/inventory/customers?deep=[{s_key:'customer_id',t_col:'orders',t_key:'customer_id',isMultiple:true,select:'order_no,total'}]
{
    "success": true,
    "statusCode": 200,
    "data": [
        { "customer_id": [ { "order_no": 1001, "total": 12900, "customer_id": 1 } ], "first_name": "Bob", "last_name": "Lin" }
    ]
}

The orders take the place of customer_id. To keep the id, use a virtual field. Every option of deep is on its page.

Good to know

  • Cache. With caching on, the answer comes from Redis until a write through API Maker changes the table. The groups of the caller are checked first, but the hooks do not run for a cached answer. x-am-cache-control: reset_cache reads the database again.
  • Hooks. A pre hook can add conditions to g.req.query.find, for example the rows of the person who calls. A post hook can change g.res.output.
  • Big tables. To read every row of a big table, use get all by stream.

From your code

g.sys.db.getAll makes the same call from custom APIs, hooks, events, schedulers and test cases.

Without a schema : /api/gen

Every table also answers this operation under /api/gen, with or without a schema :

URL /api/gen/admin/mysql8/inventory/customers
API id GEN_GET_ALL
From code g.sys.db.gen.getAllGen

A filter matches the value as you send it : "22" does not match the number 22. On MongoDB, a text that looks like an ObjectId is turned into one. deep needs its t_col, and works from a MongoDB collection only.

Headers and errors

This operation takes the request headers of every API. It answers the envelope, with the status codes and the messages of every API.

Related : All APIs · Table schema · Pre hooks · Post hooks · API group permission