Remote / foldkit-remote-drizzle

EntityBinding

interface · packages/remote-drizzle/src/binding.ts:131

interface EntityBinding<
  Name extends string,
  Table extends DrizzleTable,
  F extends Schema.Struct.Fields = Schema.Struct.Fields,
  Relations extends Record<string, RelationBinding> = Record<
    string,
    RelationBinding
  >,
> extends EntityDescriptor<Name, F> {
  readonly table: Table
  readonly columns: Readonly<Record<string, AnyColumn>>
  readonly relations: Relations
  readonly computed: Readonly<Record<string, ComputedConfig>>
  readonly visible?: Visible | undefined
  readonly invariants: ReadonlyArray<Invariant>
  readonly clocked?: ReadonlyArray<string> | undefined
  readonly operators: BindingOperators
  readonly reach?:
    | ((owner: EntityIdentity<string>) => Option.Option<AnyEntityBinding>)
    | undefined
  readonly cascades?: ReadonlyArray<CascadeEdge> | undefined
  readonly restricts?: ReadonlyArray<PointerEdge> | undefined
  readonly clears?: ReadonlyArray<PointerEdge> | undefined
  readonly guards?: ReadonlyArray<string> | undefined
  readonly keyed?: ReadonlyArray<string> | undefined
}

In the guides

Members

EntityBinding.table

property · packages/remote-drizzle/src/binding.ts:137

readonly table: Table

EntityBinding.columns

property · packages/remote-drizzle/src/binding.ts:138

readonly columns: Readonly<Record<string, AnyColumn>>

EntityBinding.relations

property · packages/remote-drizzle/src/binding.ts:139

readonly relations: Relations

EntityBinding.computed

property · packages/remote-drizzle/src/binding.ts:140

readonly computed: Readonly<Record<string, ComputedConfig>>

EntityBinding.visible

property · packages/remote-drizzle/src/binding.ts:147

readonly visible?: Visible | undefined

Which rows a principal may see at all; undefined for every row. It is on the binding because a table is read four ways (by id, as the children of a relation, as the target of a ref, through a query) and a rule on one of them would leave three open. A row it hides is, to that principal, not there.

EntityBinding.invariants

property · packages/remote-drizzle/src/binding.ts:153

readonly invariants: ReadonlyArray<Invariant>

What every row must hold, from the bound Entity (Entity.invariant): a writer judges the row it would leave against each. None for a binding made from a table alone (entity).

EntityBinding.clocked

property · packages/remote-drizzle/src/binding.ts:159

readonly clocked?: ReadonlyArray<string> | undefined

The fields the bound Entity sets from the write's clock (Entity.sets with Expr.now): a retry stamps them anew, so a writer telling a retry from another write leaves them out. None for a binding made from a table.

EntityBinding.operators

property · packages/remote-drizzle/src/binding.ts:166

readonly operators: BindingOperators

How its expressions' primitive operators run: in SQL (queries, when, invariants, Read rules) and in memory (a predicate decided from the input alone, a write's miss explained, an insert judged). Both kernels unless given (bind(…, { operators })).

EntityBinding.reach

property · packages/remote-drizzle/src/binding.ts:172

readonly reach?:
  | ((owner: EntityIdentity<string>) => Option.Option<AnyEntityBinding>)
  | undefined

The binding of each Entity bound beside this one, by identity: what a body's path or exists reaches. bind sets it; a binding made with entity reaches nothing.

EntityBinding.cascades

property · packages/remote-drizzle/src/binding.ts:179

readonly cascades?: ReadonlyArray<CascadeEdge> | undefined

The relations of Entities bound beside this one that a delete of its row cascades through (Relation.one(…, { onDelete: 'cascade' })): what the writer removes with the row. bind sets it; a binding made with entity cascades into nothing.

EntityBinding.restricts

property · packages/remote-drizzle/src/binding.ts:185

readonly restricts?: ReadonlyArray<PointerEdge> | undefined

The relations of Entities bound beside this one that refuse a delete of a row they point at (Relation.one(…, { onDelete: 'restrict' })). bind sets it; a binding made with entity restricts nothing.

EntityBinding.clears

property · packages/remote-drizzle/src/binding.ts:191

readonly clears?: ReadonlyArray<PointerEdge> | undefined

The relations of Entities bound beside this one whose link a delete of the row they point at clears (Relation.one(…, { optional: true, onDelete: 'setNull' })). bind sets it; a binding made with entity clears nothing.

EntityBinding.guards

property · packages/remote-drizzle/src/binding.ts:198

readonly guards?: ReadonlyArray<string> | undefined

The keys of this Entity's own one relations declared onDelete, whose links the writer refuses to point at a row that is not there. bind sets it; a binding made with entity knows no onDelete, so its writer does not say it checks a link (EntityWriter.checksTargets).

EntityBinding.keyed

property · packages/remote-drizzle/src/binding.ts:200

readonly keyed?: ReadonlyArray<string> | undefined

The keys of this Entity's own one relations whose table declares a foreign key on their column. bind sets it.