# Interface: CollectionDefinition\<N, S, L, M\>

Defined in: [packages/core/src/schema/collection-def.ts:60](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L60)

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`](https://minca.dev/api/core/interfaces/DefineCollection.md), `"name"` \| `"schema"` \| `"links"` \| `"computed"` \| `"contract"`\>

## Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
| <a id="type-parameter-n"></a> `N` *extends* `string` | `string` |
| <a id="type-parameter-s"></a> `S` | \| [`JsonSchema`](https://minca.dev/api/core/type-aliases/JsonSchema.md) \| [`StandardJSONSchemaV1`](https://minca.dev/api/core/interfaces/StandardJSONSchemaV1.md) |
| <a id="type-parameter-l"></a> `L` | `Readonly`\<`Record`\<`string`, `LinkDeclaration`\>\> |
| <a id="type-parameter-m"></a> `M` *extends* [`ComputedResult`](https://minca.dev/api/core/type-aliases/ComputedResult.md) | [`ComputedResult`](https://minca.dev/api/core/type-aliases/ComputedResult.md) |

## Properties

| Property | Modifier | Type | Description | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ |
| <a id="property-computed"></a> `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](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L74) |
| <a id="property-contract"></a> `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](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L80) |
| `contract.check?` | `readonly` | \| readonly [`Contract`](https://minca.dev/api/core/interfaces/Contract.md)[] \| ((`scope`) => `Readonly`\<`Record`\<`string`, [`BoolLike`](https://minca.dev/api/core/type-aliases/BoolLike.md)\>\>) | - | - | [packages/core/src/schema/collection-def.ts:81](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L81) |
| `contract.line?` | `readonly` | [`Line`](https://minca.dev/api/core/interfaces/Line.md) | - | - | [packages/core/src/schema/collection-def.ts:84](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L84) |
| <a id="property-description"></a> `description?` | `readonly` | `string` | - | [`DefineCollection`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`description`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-description) | [packages/core/src/node/types.ts:326](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L326) |
| <a id="property-history"></a> `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`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`history`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-history) | [packages/core/src/node/types.ts:340](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L340) |
| <a id="property-links"></a> `links?` | `readonly` | `L` | - | - | [packages/core/src/schema/collection-def.ts:68](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L68) |
| <a id="property-name"></a> `name` | `readonly` | `N` | - | - | [packages/core/src/schema/collection-def.ts:66](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L66) |
| <a id="property-rules"></a> `rules?` | `readonly` | [`CollectionRules`](https://minca.dev/api/core/interfaces/CollectionRules.md) | What must be unique, which fields are fixed, whether records are written once: every peer checks. None by default | [`DefineCollection`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`rules`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-rules) | [packages/core/src/node/types.ts:344](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L344) |
| <a id="property-schema"></a> `schema` | `readonly` | `S` | - | - | [packages/core/src/schema/collection-def.ts:67](https://github.com/leifriksheim/minca/blob/main/core/src/schema/collection-def.ts#L67) |
| <a id="property-title"></a> `title?` | `readonly` | `string` | - | [`DefineCollection`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`title`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-title) | [packages/core/src/node/types.ts:325](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L325) |
| <a id="property-topics"></a> `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`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`topics`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-topics) | [packages/core/src/node/types.ts:350](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L350) |
| <a id="property-version"></a> `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`](https://minca.dev/api/core/interfaces/DefineCollection.md).[`version`](https://minca.dev/api/core/interfaces/DefineCollection.md#property-version) | [packages/core/src/node/types.ts:334](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L334) |
