Default Fields

Every record contains several default fields that are managed automatically by RONIN.

ID

The most important default field generated by RONIN (whenever a new record is created) is the “ID” field, which has the slug id and contains an identifier of the record that is unique within your entire Space (across all Schemas).

For example, such an ID might look like this:

rec_vais0g9rrk995tz0

The ID always consists of the following parts:

  • The ID Prefix, consisting of 3 letters.

  • An underscore character (_) used as a separator.

  • A collision-proof unique identifier, consisting of 16 alpha-numeric characters.

Customizing IDs

In order to change the ID Prefix from rec (which is short for “record”) to any other letter sequence of your choice, you may do so using the “ID Prefix” field in the “Settings” section of your schema on the dashboard. For example, you might use the prefix acc for a schema named “Account”.

However, please note that changing this setting only applies to records created after you’ve updated the setting, so you may need to run a manual migration, or create a new schema with the right ID Prefix set from the beginning.

If this isn’t enough for you, you may also overwrite the id field entirely, by passing it when creating or updating a record:

await create.account.with({
  id: 'account_vais0g9rrk995tz0',
  name: 'Elaine',
  handle: 'elaine'
});

In favor of consistency (within the RONIN platform, but also among different services available on the web), we recommend sticking to the default format.

Metadata

Whenever a record is created or updated, RONIN automatically stores and updates a ronin field that contains meta-information about the record:

interface Metadata {
  createdAt: Date | string;
  updatedAt: Date | string;
  createdBy: `acc_${string}`;
  updatedBy: `acc_${string}`;
  locked: boolean;
}

Although this information is entirely read-only (and therefore cannot be overwritten), you may use it to filter or order records when querying:

await get.blogPosts.orderedBy.ascending(['ronin.createdAt']);

await get.blogPosts.with.ronin.createdAt.lessThan(new Date());

await get.blogPosts.with.ronin.locked(true);

Note that, even though they might look like record references, the ronin.createdBy and ronin.updatedBy fields are managed automatically and internally by RONIN, just like all the other field that are nested into ronin, which means you won’t be able to resolve them using the including query instruction.