API Maker

The backend engine for the AI era

Chapters

What you will learn

  • A virtual field, declared in the schema
  • A customer and their orders, with isMultiple
  • Three databases, one answer
  • Products and their stock in SQL Server
  • find, sort, limit, select and nesting on every level
  • Two rules to keep, and how it runs in chunks
In the docsTable schema
Transcript737 words · click a time to play from there

Intro

Deep fills an ID with the row it points to. A virtual field goes the other way. It brings the rows of another table that point back here, like the orders of a customer. One call does it, even from another database.

The other side of a relation

The other side of a relation is usually extra work. You make a second query for every parent, or a GROUP BY, and then you group the rows again in code. You need a glue service when the children are in another database. And every caller writes the same lookup again. With API Maker, one property in the schema names the children. Deep fills it, with one query for up to a thousand parents, across any two databases.

And every caller uses the same name. In this video: how to declare it, a customer with their orders, three databases in one answer, products with their stock, shaping and nesting, and the rules to know.

The declaration

In Instance API, pick postgres, then crm, then customers, and open its schema. The last properties are virtual fields: orders, reviews, and tickets. No column holds them. s_columnVirtualLinker names the column of this table, the ID. And t_columnVirtualLinker names the column of the other table that holds it, customer_id. Instance, database, and table name the other table. The orders are in MySQL.

A customer and their orders

Now in API Testing, we use Query for get data on customers. We ask for customer thirty five, and in deep, for orders, with isMultiple true to get a list. Send. We get Gabriel Souza, with three orders from MySQL, even though a customer row has no column for them.

Three databases, one answer

Now three virtual fields at once. The reviews are in MongoDB. The support tickets are in the same PostgreSQL database. Send. One answer has orders from MySQL, reviews from MongoDB, and tickets from PostgreSQL. Three databases, one call, and no code.

Products and their stock

It works from any database to any other. Here are two products in MongoDB, with warehouse_stock, sorted by warehouse. Send. Each product gets one row for each warehouse, from SQL Server. The Aurora desk lamp has twenty eight in the first warehouse, and fifty four in the second.

Shape and nest

An item of a virtual field takes the keys of a query. We ask for three gold customers. On their orders, we want the delivered ones, sorted by total, one each. And inside each order, its lines, because items is a virtual field of orders. Send. Each customer comes with their biggest delivered order, and its lines. Jonas has no delivered order, so the field is not there.

The rules

There are two rules. First, the select of the item must keep the linker, customer_id. Without it, nothing can be matched, and no orders come back, with no error. Second, a virtual field is not a column, so you cannot filter on it. A find on orders dot status is refused, with a four hundred that names the field. To filter by a linked table, filter the table that holds the link.

The next video shows how. How does it run? API Maker reads the parents, collects their IDs, and asks the other table once for every thousand parents, with an IN list. Then it gives each parent its rows. A limit applies to each list after the read. With fetchingTechnique one_by_one, it asks once for each parent instead, and the database applies skip and limit. That is better when each parent has thousands of children.

The size of a chunk is a setting too.

Writes and code

The same names work for writes. Master save takes the orders of a customer under orders, and saves them in MySQL. Video nine shows it. From code, g.sys.db takes the same deep, with types, in eight languages. And the other table is read through its own query API, with the access of the caller, like every deep.

Built on standards

A relation is written once, in the schema, which lives in Git. Every caller, and every AI assistant, uses the same name, so the code looks the same everywhere. And the answer has the same shape on every database.

Recap

To sum up. A virtual field names the rows that point back. Deep with isMultiple fills it, across databases. Find, sort, limit, select, and nesting work on every level. Keep the linker in the select, and filter on the side that holds the link. Next: find and join, to filter by linked tables. API Maker. Build faster, spend smarter, deliver better.