ResourceModel
ResourceModel =
object
Defined in: packages/schema/src/model.ts:122
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().
Properties
Section titled “Properties”author?
Section titled “author?”
optionalauthor?:string
Defined in: packages/schema/src/model.ts:157
The field holding the id of the user who created the record (.author()): creates set it, no request may.
buckets?
Section titled “buckets?”
optionalbuckets?:BucketsModel
Defined in: packages/schema/src/model.ts:201
The resource it is a time rollup of, and how (.bucketsOf()): the database writes its rows, the API only reads them.
checks?
Section titled “checks?”
optionalchecks?:Record<string,CheckModel>
Defined in: packages/schema/src/model.ts:199
The database checks whose refusal the API names, by constraint name, each with the label shown for it
(.checks()).
comments?
Section titled “comments?”
optionalcomments?:true
Defined in: packages/schema/src/model.ts:178
Whether people who may read its records comment on them (.comments()).
derived?
Section titled “derived?”
optionalderived?:DerivedModel[]
Defined in: packages/schema/src/model.ts:203
The values worked out from other records for each of its records, kept current by Protobase (.derive()).
etagFrom?
Section titled “etagFrom?”
optionaletagFrom?:string
Defined in: packages/schema/src/model.ts:187
The field whose change makes a record’s new ETag (.etagFrom()), in place of a version or updated_at column found by name.
events?
Section titled “events?”
optionalevents?:EventModel[]
Defined in: packages/schema/src/model.ts:172
The events its changes raise (.events()), the catalogue subscriptions pick from.
explicitGrants?
Section titled “explicitGrants?”
optionalexplicitGrants?:true
Defined in: packages/schema/src/model.ts:189
Whether role wildcards such as *.read leave it out, so only * and capabilities naming it grant it (.explicitGrants()).
fields
Section titled “fields”fields:
Record<string,FieldModel>
Defined in: packages/schema/src/model.ts:133
Its fields, by field name: each a column of its table.
history?
Section titled “history?”
optionalhistory?:true
Defined in: packages/schema/src/model.ts:174
Whether every change of its records is kept, with who made it (.history()).
historyIgnore?
Section titled “historyIgnore?”
optionalhistoryIgnore?:string[]
Defined in: packages/schema/src/model.ts:176
The fields whose changes are not captured (.history({ ignore })): an update of only those keeps nothing.
links?
Section titled “links?”
optionallinks?: readonly [string,string]
Defined in: packages/schema/src/model.ts:170
The two relations a link resource joins (.links()), so each side lists the other at /{parent}/{key}/{resource}.
optionallive?:true
Defined in: packages/schema/src/model.ts:180
Whether open pages refresh as soon as its records change (.live()).
liveReads?
Section titled “liveReads?”
optionalliveReads?:string[]
Defined in: packages/schema/src/model.ts:185
The resources whose changes refresh its open pages in place of its own (.live({ reads })), for one backed by a
database view: its own table is not captured, and a change names no record of it.
lookups?
Section titled “lookups?”
optionallookups?:Record<string,FieldModel>
Defined in: packages/schema/src/model.ts:138
Its lookup fields, by field name (.lookup()): each shows a field of a linked record and has no column of its own.
A read’s model, such as /meta’s, has those the caller may read among its fields instead.
name:
string
Defined in: packages/schema/src/model.ts:124
The resource’s name: its address (/api/v1/<name>, /<name> in the admin) and how other config refers to it.
openExisting?
Section titled “openExisting?”
optionalopenExisting?:string[]
Defined in: packages/schema/src/model.ts:194
The fields of a unique key whose conflict on create answers the record already holding those values, to a caller
who may read it (.openExisting()).
owner?
Section titled “owner?”
optionalowner?:string
Defined in: packages/schema/src/model.ts:155
The field holding the owning user’s id; .own capability scopes filter on it.
parents?
Section titled “parents?”
optionalparents?:ParentModel[]
Defined in: packages/schema/src/model.ts:168
The records its records belong to, and the access on them writing its records needs (.parent()).
position?
Section titled “position?”
optionalposition?:object
Defined in: packages/schema/src/model.ts:159
The integer field holding the records’ order by hand (.position()), 1 the first.
after?
Section titled “after?”
optionalafter?:PositionAfterModel
The records each record ranks after while they are pending, such as the tasks it waits for (.position(..., { after })).
field:
string
The integer field, 1 the first record.
within?
Section titled “within?”
optionalwithin?: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
Section titled “primaryKey”primaryKey:
string[]
Defined in: packages/schema/src/model.ts:140
The fields of its key, in order; records are addressed by it.
search?
Section titled “search?”
optionalsearch?:string[]
Defined in: packages/schema/src/model.ts:151
Field names that the bare-text search filter matches against.
searchMatch?
Section titled “searchMatch?”
optionalsearchMatch?:Record<string,SearchMatch>
Defined in: packages/schema/src/model.ts:153
How a search field matches when not by containing the word; see SearchMatch.
softDelete?
Section titled “softDelete?”
optionalsoftDelete?:string
Defined in: packages/schema/src/model.ts:142
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:126
The table it reads and writes.
name:
string
The table’s name.
schema?
Section titled “schema?”
optionalschema?:string
The table’s schema; the search path decides when omitted.
tenant?
Section titled “tenant?”
optionaltenant?:string
Defined in: packages/schema/src/model.ts:144
The field that separates tenants: every query is limited to the caller’s tenant (.tenant()).
tenantAcross?
Section titled “tenantAcross?”
optionaltenantAcross?:"memberships"
Defined in: packages/schema/src/model.ts:149
memberships: lists also read the other tenants the caller is a member of, each as the caller’s role there allows
(.tenant(pick, { across })); a record’s own reads and every write stay in the caller’s tenant.