Entity / foldkit-entity

Sixty seconds: describe one read

ts
import { Schema } from 'effect'
import { Entity, type Selected } from 'foldkit-entity'

const Task = Entity.define('Task', Schema.Struct({
  id: Schema.String,
  title: Schema.String,
  done: Schema.Boolean,
}))
const TaskTitle = Entity.select(Task, { id: true, title: true })
type TaskTitle = Selected<typeof TaskTitle> // the value it reads
const value: TaskTitle = { id: 't1', title: 'Read the guide' }

Task describes the domain. TaskTitle describes one consumer's result shape; it does not query a database or allocate a cache. Its schema validates that shape when an interpreter produces data. A selection does not include done unless you select it.

Next, hand the Entity to Remote for client reads or bind it to Drizzle tables on the server. Declare operation input separately when adding a form: selecting readable fields does not grant permission to write them.