MCPcopy Create free account
hub / github.com/Effect-TS/effect / declaredKey

Function declaredKey

packages/effect/src/eventlog/EventRow.ts:630–642  ·  view source on GitHub ↗
(declaration: KeyDeclaration<any, string>, fields: Schema.Struct.Fields)

Source from the content-addressed store, hash-verified

628})
629
630const declaredKey = (declaration: KeyDeclaration<any, string>, fields: Schema.Struct.Fields): RowKey => {
631 const names = declaration.fields
632 const derive = declaration.derive
633 return {
634 fields: names,
635 schema: Schema.Struct(Struct.pick(fields, names) as Schema.Struct.Fields),
636 fromRow: (row) => Struct.pick(row, names),
637 toValues: (key) => key as Row,
638 primaryKey: derive !== undefined
639 ? (row) => derive(Struct.pick(row, names) as any)
640 : jsonKey(names.map((name) => [name, fields[name]]), false)
641 }
642}
643
644// A string single-field key is its own primary key. Otherwise the key is the
645// JSON tuple of the fields' JSON encodings, distinct for distinct values of

Callers 1

makeFunction · 0.85

Calls 4

deriveFunction · 0.85
jsonKeyFunction · 0.85
pickMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected