- Being able to reuse a Effect Schema to a db schema through a magic function
- We want to be able to map multiple flavors, including representing a struct just as a string column, or a json column
- The system takes care of transforming the struct into the db shape and back
- Concrete DB flavours (e.g. SQLite, Postgres, etc) are implemented separately
export const User = Schema.Struct({
id: Schema.String,
name: Schema.String,
})
const user: User = Schema.decodeSnyc({
id: 'bob',
name: 'Bob',
})(User)
// save user
await magicDbFunction.persist(user)
// get user
const myUser: User = await magicDbFunction.get(user)
- Caveats
- Only works for structs
- No control of number types (always uses reals/floats)
dbcli codegen --schema ./src/db-schema.ts --output ./src/drizzle-db-schema.ts
import {gen} from 'framework'
gen(struct, './lol.ts')
- Thanks a lot to @timsuchanek for contributing the initial version of the Drizzle codegen tool