IDs
How to generate IDs with ID.unique(), when to choose your own and which characters are valid.
Every resource has an ID ($id): row, table, database, user, file, bucket, team, function. On creation, you choose between letting the SDK generate one or providing your own.
import { ID, TablesDB } from '@owbase/web';import { client } from './client';
const db = new TablesDB(client);
// ID generated by the SDK: unique, with nothing for you to keep track of.await db.createRow({ databaseId: 'store', tableId: 'orders', rowId: ID.unique(), data: { customer: 'Ana', total: 120 } });
// ID chosen by you: useful when it comes from another system.await db.createRow({ databaseId: 'store', tableId: 'orders', rowId: ID.custom('order-2026-0001'), data: { customer: 'Bia', total: 80 } });Rules for an ID you choose
Section titled “Rules for an ID you choose”- Up to 36 characters.
- Only
a-z,A-Z,0-9, period (.), hyphen (-) and underscore (_). - It can’t start with a special character.
- Unique within its scope: two rows in the same table can’t have the same ID (the error is
row_already_exists, status 409).
When to use each
Section titled “When to use each”ID.unique(): the default. Avoids collisions and reveals nothing about the resource.ID.custom('…'): when the ID comes from another system (order number, product code) or when you want a readable address, such as a table calledordersor a bucketphotos.
Fields that start with $ ($id, $createdAt, $updatedAt, $permissions) belong to the system and come in every response.
Was this page helpful?Thanks for your feedback.