← @mortar-kit/core

CollectionWriteinterface

import { CollectionWrite } from '@mortar-kit/core'

interface CollectionWrite<F extends Fields = Fields>

A write to one of a collection's documents, as the collection's canWrite sees it.

Properties

user: any

Who is writing: the user auth.require returned in createContentServer (e.g. what allowMembers({ fields }) builds). Typed loosely, since collections are declared without the app's auth.

action: "save" | "remove" | "move"

The content server function called.

id: string

The document's id.

doc?: Doc<Record<string, unknown>>

The document being saved, as sent (save only; not validated yet).

stored: Doc<InferFields<F>> | null

The document as stored now; null when a save creates it. Check it too, so a save can't change an owner field to get past the rule.