Passing Date to SQL Model in TypeScript

How do I pass the date to a SQL model?

export class UserModel extends Model.Class<UserModel>("auth/UserModel")({
    id: Model.Generated(UserId),
    name: Schema.NonEmptyTrimmedString,
    createdAt: Model.DateTimeInsert,
    updatedAt: Model.DateTimeUpdate
}) {}

export const make = Effect.gen(function*() {
    const repo = yield* Model.makeRepository(UserModel, {
        tableName: "users",
        spanPrefix: "UsersRepo",
        idColumn: "id"
    })

    return { ...repo } as const
})

export class UsersRepo extends Effect.Tag("auth/UsersRepo")<
    UsersRepo,
    Effect.Effect.Success<typeof make>
>() {
    static Live = Layer.effect(UsersRepo, make).pipe(Layer.provide(SqlLive))
    // static Test = makeTestLayer(UsersRepo)({})
}

const program = Effect.gen(function*() {
  const repo = yield* UsersRepo
  const timestamp = yield* DateTime.now;
  const user = yield* repo.insert({ name: "test", createdAt: timestamp, updatedAt: timestamp }) // ERROR HERE: Type 'Utc' is not assignable to type 'Utc & Brand<"Override">'. Property '[BrandTypeId]' is missing in type 'Utc' but required in type 'Brand<"Override">'
  yield* Effect.log(user)
})
Was this page helpful?