Skip to content

register()

ts
admin.register("User");
admin.register("Post", config);

Chainable. Call only before mount().

config is ModelConfig. Every property is optional.

List

KeyTypeDefault
listDisplaystring[]Display field + scalars (max 6) + createdAt
listFilterstring[][] (opt-in)
searchFieldsstring[]Non-id string scalars
defaultSort{ field, direction }createdAt desc or id desc
perPagenumber50
pluralNamestringLowercase English plural
displayFieldstringAuto-detected label field

Fields

ts
fields?: Record<string, { exclude?: boolean; expose?: boolean; readOnly?: boolean }>

See Forms and Sensitive fields.

Trust

KeyTypeDefault
permissions{ list?, view?, create?, update?, delete?, actions? }omitted = allow authenticated
scope(adminUser) => Promise<Record<string, unknown>>{}

Omitted permission keys allow every signed-in admin. [] denies everyone except isSuperAdmin. Super-admin skips allowlists, not scope.

Extend

KeySignature
actions{ name, label, handler, allowedRoles? }[]
beforeCreate(data) => Promise<data>
afterCreate(record) => Promise<void>
beforeUpdate(id, data) => Promise<data>
afterUpdate(record) => Promise<void>
beforeDelete(id) => Promise<void>
afterDelete(id) => Promise<void>

Action handler is ({ ids, adminUser, client, where }) => Promise<{ message: string }>. client is the ORM handle (Prisma client or TypeORM DataSource). where is { scope, ids }, not an ORM query object.

Not on this object (yet)

fieldsets, inlines, and widget overrides exist in the architecture notes. They are not accepted by the shipped ModelConfig.

Released under the MIT License.