API Maker

The backend engine for the AI era

Chapters

What you will learn

  • A tree across PostgreSQL and MySQL, in one call
  • The ids filled in for you
  • One bad line: nothing written anywhere
  • The tree saved, and read back with deep
  • How master save writes it
In the docsMaster save
Transcript502 words · click a time to play from there

Intro

One call can save a tree of rows: a customer in PostgreSQL, and her order and its lines in MySQL. And if one row is wrong, nothing is saved, in any database.

A tree of rows, the usual way

Saving a customer with her first order is usually hard. You make three calls, one for each table, in the right order. You carry the IDs by hand, from one call to the next. And if it fails halfway, half an order stays behind, because no transaction can span two databases. With API Maker, you send one master save, with the tree as it is. Each row gets the ID of the row it belongs to.

And if anything fails, everything is taken back, in every database. In this video: a tree across two databases, one bad line, the tree saved, and the tree read back.

A tree across two databases

Open API Testing. Pick postgres, then crm, then customers, and the API Master save. We type a new customer, Tara Kapoor. Under orders is her first order, saved in MySQL. This is the virtual field of video eleven. Under items are its two lines, also in MySQL. But the second quantity is written in words.

All or nothing

Send. The answer is four hundred, about the quantity of a line. The customer was already saved in PostgreSQL, and the order and the first line in MySQL. All three were taken back. Nothing is left, in either database. We change it to two, as a number. Send again. The answer is two hundred and one, with the customer and her new ID. Her order got that ID as its customer_id, and each line got the ID of the order.

Read back

Now pick Query for get data. We ask for her by email, with deep on her orders, and their items. Send. We get the customer from PostgreSQL, and her order and its two lines from MySQL, in one answer.

How it is written

How does it work? The writes follow the relations. A row that a field points to is saved first, and its ID is written into that field. The rows under a virtual field are saved after their parent, with its ID. Every write is noted. When one fails, the others are taken back, the last one first.

Good to know

Good to know. A row that has its primary key is updated, not inserted. So one tree can save and update. Every row goes through the schema of its own table, with its rules. From code, g.sys.db.masterSave does the same thing. And if taking back a write fails, the answer says so, next to the error that started it.

Built on standards

One call, for a tree of rows. All or nothing, across databases. So a client, written by you or by an AI assistant, never leaves half an order behind.

Recap

To sum up. One master save, for a tree across databases. Each row gets the ID it needs. One bad row, and nothing is saved anywhere. And deep reads the tree back. Next: deep populate, in depth. API Maker. Build faster, spend smarter, deliver better.