Table conventions in Gista.js

Every table in Gista.js follows a few conventions. You don't have to memorize them — the helpers handle the details — but knowing what each column does will help you understand the code.

id — internal, never shared

Every table has an id column: an auto-incrementing integer (1, 2, 3, ...). It's the primary key the database uses to identify rows. You use it internally — in foreign keys, in queries, in model methods like findByID. But you never put it in a URL or send it to a browser.

Why not? Sequential IDs leak information. If a user sees /forms/42, they know there are at least 42 forms. They can guess /forms/41 or /forms/43 and maybe access someone else's data.

public_id — safe to share

That's where public_id comes in. It's a random hex string like a7f3b9c1e2d4 — generated automatically when a row is created. This is the ID you put in URLs, API responses, and anything a user can see. It doesn't reveal order or count, and it can't be guessed.

The model gives you findByPublicID to look up rows by this column.

created_at / updated_at — automatic timestamps

These columns record when a row was created and last updated. They're set automatically — created_at when the row is inserted, and both default to the current time. You never need to pass them manually.