CollectionDefinitioninterface
import { CollectionDefinition } from '@mortar-kit/core'
interface CollectionDefinition<F extends Fields>What a developer passes to defineCollection.
Properties
name: stringStable identifier, also the storage folder. Lowercase, e.g.
postsorcase-studies.label?: stringPlural name for the admin panel ("Posts"). Defaults to
name.fields: FThe fields every document has, built with
fields.*.body?: booleanWhether documents also have brick entries (a body made of bricks). Default false.
title?: keyof F & stringA
textfield shown as the document's title in lists and pickers. Defaults to the firsttextfield; without one, the slug is shown.sort?: SortOrder<keyof F & string>The default list order. Defaults to the title field (or the slug), ascending. With
orderable, lists follow the manual order instead and this orders only documents that have no place in it yet.orderable?: booleanWhether editors put the documents in order by hand (drag or move up/down in the admin). Lists then follow that order unless they pass a
sort, and new documents go to the end. The order is kept in each document'sposition, whichcreateContentmanages. Default false.reservedSlugs?: readonly string[]Slugs documents may not use, e.g. the app's own route segments next to
/:slug(admin). Segments other collections'urls start with are refused anyway (seeurl).url?: stringWhere a document is on the site: a path with one
:slugsegment, e.g./posts/:slugor/:slug. One pattern drives the app's route (the same syntax as @solidjs/router), links (urlOf), the admin's preview links, and the sitemap; next to/posts/:slug, a/:slugcollection can't use the slugposts. Mortar doesn't route: the app still declares its routes, from this.home?: stringWith
url: the slug of the document at the pattern's prefix instead, e.g.homeat/for/:slug.canWrite?: (write: CollectionWrite<F>) => boolean | Promise<boolean>Who may change this collection's documents, checked by
createContentServerafter its owncanWrite(both must allow): false refuses the write with a 403. Gets the user, the document as stored and, for a save, the one sent, so a rule can be scoped to the document (only the projects someone belongs to).