Three columns do special work in almost every table: the id, the timestamps, and the owner. Each is a setting on the resource.

Ids

Every record has a primary key, id by default. Choose its type when you create the resource (it can’t be changed later): New resources use ULIDs or UUIDs; existing integer-keyed tables keep working and can be re-saved. ULIDs sort by time, so ordering by id is the same as ordering by creation. Studio: Settings → ID type and Primary key (the column name, default id). Don’t send an id on create. Pawabase assigns it, and returns it in the response.

Timestamps

With timestamps: true (the default), every record has: They are ISO 8601 strings in UTC. They are read-only: your writes can’t set them. Order by them for “newest first”:
Studio: Settings → Timestamps (“Maintain created_at and updated_at”). Turn it off only for a table whose own columns already hold these times. The Time zone setting (Africa/Lagos, Europe/Berlin) on the resource is for presenting and for schedules that read it; stored times stay UTC. Empty means UTC.

The owner column

Many tables belong to a person. Set owner_field to the column that holds their id: Settings → Owner field. Filled with the caller’s user id on create. Two things then happen:
  1. On create, the column is filled with the signed-in person’s id, so your app doesn’t need to send it (and a person can’t create a record for someone else).
  2. The owner rule compares that column with the caller on every list, get, update and delete.
If you use a different column name per relationship (author_id, customer_id), pass it to the rule as Owns the record (author_id). See Access rules: writing rules.
If the owner column ends up empty (a record created by a server without a user), the owner rule never matches it, and nobody but a secret key can see it. Set the owner explicitly when your server creates records on someone’s behalf.

Organization scoping

For team data, add an org column and a rule that compares it with the caller’s active organization:
  • All of these rules pass:
    • Check a value: $auth.org is set
    • Compare values: $record.org equals $auth.org
Set org: session.org on create. See Organizations.

Columns and types

Your own columns.

Access rules

Owner-only recipes.