Skip to content

ResourceModel

ResourceModel = object

Defined in: packages/schema/src/model.ts:86

A resource as the server and the app see it: a table, its fields and what the API does with them, built by resource(...).toModel(); see resource().

optional comments?: true

Defined in: packages/schema/src/model.ts:122

Whether people who may read its records comment on them (.comments()).


optional events?: EventModel[]

Defined in: packages/schema/src/model.ts:118

The events its changes raise (.events()), the catalogue subscriptions pick from.


fields: Record<string, FieldModel>

Defined in: packages/schema/src/model.ts:97

Its fields, by field name.


optional history?: true

Defined in: packages/schema/src/model.ts:120

Whether every change of its records is kept, with who made it (.history()).


name: string

Defined in: packages/schema/src/model.ts:88

The resource’s name: its address (/api/v1/<name>, /<name> in the admin) and how other config refers to it.


optional owner?: string

Defined in: packages/schema/src/model.ts:109

The field holding the owning user’s id; .own capability scopes filter on it.


optional position?: object

Defined in: packages/schema/src/model.ts:111

The integer field holding the records’ order by hand (.position()), 1 the first.

field: string

The integer field, 1 the first record.

optional within?: string

The relation whose records each have an order of their own, as an invoice’s items do; one order for all records when omitted.


primaryKey: string[]

Defined in: packages/schema/src/model.ts:99

The fields of its key, in order; records are addressed by it.


optional search?: string[]

Defined in: packages/schema/src/model.ts:105

Field names that the bare-text search filter matches against.


optional searchMatch?: Record<string, SearchMatch>

Defined in: packages/schema/src/model.ts:107

How a search field matches when not by containing the word; see SearchMatch.


optional softDelete?: string

Defined in: packages/schema/src/model.ts:101

The field a delete sets instead of removing the row, and lists leave such rows out (.softDelete()).


table: object

Defined in: packages/schema/src/model.ts:90

The table it reads and writes.

name: string

The table’s name.

optional schema?: string

The table’s schema; the search path decides when omitted.


optional tenant?: string

Defined in: packages/schema/src/model.ts:103

The field that separates tenants: every query is limited to the caller’s tenant (.tenant()).