import { Schema } from "effect"
import { Model } from "effect/schema"
export const UserId = Schema.String.pipe(Schema.brand("UserId"))
export type UserId = typeof UserId.Type
// `Model.Class` derives variants for the database (`User`, `User.insert`,
// `User.update`) and the JSON API (`User.json`, `User.jsonCreate`,
// `User.jsonUpdate`) from a single field declaration.
export class User extends Model.Class<User>("User")({
// A UUID v4 primary key generated by the application on insert. It is
// excluded from the `jsonCreate` / `jsonUpdate` variants, so API clients can
// never set it.
id: Model.UuidV4Insert(UserId),
name: Schema.String,
email: Schema.String,
// Timestamps are managed by the model: set on insert, refreshed on update,
// and also excluded from the JSON create / update variants.
createdAt: Model.DateTimeInsert,
updatedAt: Model.DateTimeUpdate
}) {}