← @mortar-kit/core

ContentStoreinterface

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

interface ContentStore

Where documents live: raw data by collection name and slug. Implement it to keep content anywhere (files, a database, an API). Deliberately dumb; createContent applies every rule.

Properties

list: (collection: string) => Promise<unknown[]>

Every stored document of the collection, raw, each with slug set by the store (the key wins). [] if none.

get: (collection: string, slug: string) => Promise<unknown>

The raw document under slug (with slug set), or undefined. Throws if it exists but can't be read.

put: (collection: string, doc: Doc) => Promise<void>

Stores doc under doc.slug, replacing any document there.

remove: (collection: string, slug: string) => Promise<void>

Removes the document under slug; nothing happens if there is none.