Remote / foldkit-remote-drizzle
Sixty seconds: one table, one Entity, one Source
Start with a normal Drizzle table:
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
export const projects = pgTable('projects', {
id: uuid('id').primaryKey(),
name: text('name').notNull(),
status: text('status').notNull(),
})Bind it once:
import { entity, source } from 'foldkit-remote-drizzle'
const Project = entity('Project', projects)
// This is a real Remote Selection because Project is also an EntityDescriptor.
const ProjectSummary = Project.select({
id: true,
name: true,
})
// This is a RemoteServer EntitySource backed by Drizzle.
const ProjectSource = source(Project)A client requirement for:
Project:00000000-0000-4000-8000-000000000001 [id,name]causes that Source to select only the needed columns, plus whatever identity is required for normalization:
SELECT id, name
FROM projects
WHERE id IN ('00000000-0000-4000-8000-000000000001')and return a record with this Remote wire shape:
{
"id": "00000000-0000-4000-8000-000000000001",
"values": {
"id": "00000000-0000-4000-8000-000000000001",
"name": "Apollo"
}
}There is no per-screen SQL mapping. The Selection declares the semantic shape;
RemoteServer hands the Source the authorized fields; the Drizzle Source turns
those fields into columns.
pgTable, entity, select, and source above are declarations. They do not
create the table, open a database connection, or execute a query. Apply your
migrations, register the Source with RemoteServer, and provide the
database service when running its handlers. The SQL above
illustrates the selected columns; actual execution uses bound parameters.