Remote / foldkit-remote-drizzle
The binding is the shared schema
const User = entity('User', users)entity(name, table, { fields?, relations?, computed? }) derives an Effect
Schema from the Drizzle table with drizzle-orm/effect-schema and exposes the
table's columns as Remote fields.
The returned binding is simultaneously:
Drizzle table binding
+
Remote EntityDescriptor
+
relation/computed metadataThat is why this works without a second Entity declaration:
const UserSummary = User.select({
id: true,
name: true,
})A table must expose an id column. Every entity read selects the primary key for
normalization even when the client did not explicitly ask for id.
Use fields when the Remote schema should be narrower than the table or should
use an application-specific codec:
import { Schema } from 'effect'
const User = entity('User', users, {
fields: {
id: UserId,
name: Schema.String,
},
})Relation/computed fields are derived on top of that map.
Definition-time checks reject ambiguous bindings such as a relation/computed
name colliding with a scalar field, a computed field naming an invalid
relation, or a nullable singular foreign key not marked nullable.