ApiCoreInterfaces
Interface: CollectionDefinition\<N, S, L, M\>
Defined in: packages/core/src/schema/collection-def.ts:60
A collection definition as collection() takes it: its computed fields and
contract built in TypeScript, typed from its own schema and name.
Extends
Omit<DefineCollection,"name"|"schema"|"links"|"computed"|"contract">
Type Parameters
| Type Parameter | Default type |
|---|---|
N extends string | string |
S | | JsonSchema | StandardJSONSchemaV1 |
L | Readonly<Record<string, LinkDeclaration>> |
M extends ComputedResult | ComputedResult |
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
computed? | readonly | Readonly<Record<string, string>> | ((scope) => M) | Values every app derives the same way from what links to its records: ({ linked }) => ({ thumbs: linked(reaction, 'on').count() }). A view of what a node holds, not a verdict (packages/core/docs/computed.md). | - | packages/core/src/schema/collection-def.ts:74 |
contract? | readonly | object | What a version must be to count, judged by every reader: check: ({ body }) => ({ 'Why it is refused': body.amount.gte(0) }), and whether the collection is a line (packages/core/docs/contracts.md). | - | packages/core/src/schema/collection-def.ts:80 |
contract.check? | readonly | | readonly Contract[] | ((scope) => Readonly<Record<string, BoolLike>>) | - | - | packages/core/src/schema/collection-def.ts:81 |
contract.line? | readonly | Line | - | - | packages/core/src/schema/collection-def.ts:84 |
description? | readonly | string | - | DefineCollection.description | packages/core/src/node/types.ts:326 |
history? | readonly | "all" | "latest" | all keeps every version of every record whole, hash-linked, for records.history. latest, the default, keeps the current version whole and forgets what earlier ones and deleted records said | DefineCollection.history | packages/core/src/node/types.ts:340 |
links? | readonly | L | - | - | packages/core/src/schema/collection-def.ts:68 |
name | readonly | N | - | - | packages/core/src/schema/collection-def.ts:66 |
rules? | readonly | CollectionRules | What must be unique, which fields are fixed, whether records are written once: every peer checks. None by default | DefineCollection.rules | packages/core/src/node/types.ts:344 |
schema | readonly | S | - | - | packages/core/src/schema/collection-def.ts:67 |
title? | readonly | string | - | DefineCollection.title | packages/core/src/node/types.ts:325 |
topics? | readonly | readonly string[] | Fields whose values are topics, like mentions, or link roles as link:<rel>, so a node that can't read the space still matches records by them. At most 8 | DefineCollection.topics | packages/core/src/node/types.ts:350 |
version? | readonly | number | The definition's version number. Default: one past the current version, or 1. This library refuses one that isn't higher than the one in force, or not below 2^53; peers don't check it (spec 02 §6.3) | DefineCollection.version | packages/core/src/node/types.ts:334 |