Closed john093e closed 1 month ago
Why do you need your schema in client components?
Maybe I don't use it well :/
In order to create an option list for example in a table, for filtering, ordering, or to build form to create or update.
For example a "Post" table with a column "status" set to an enumerate value like "archived | editing | published", i would use like this
import {schema} from "@acme/db"
<select>
{schema.post.status.enumValues.map((status) => (
<option>{status}</option>
))}
</select>
You can define the status-enum in @acme/validators
then re-export it from there.
You can also use drizzle-zod there for getting the enum values https://orm.drizzle.team/docs/zod.
@andrewdoro , I still think you can't use schemas that came from drizzle-zod in client components. I tried it recently myself.
See: https://github.com/t3-oss/create-t3-turbo/discussions/966
@dBianchii this was introduced by this https://github.com/andrewdoro/create-t3-turbo/commit/5db63fbaf5fbfebd1209e89bf345aa1d018c540e ~~@juliusmarminge saw your PR, was thinking about a simpler solution https://github.com/t3-oss/create-t3-turbo/pull/990~~ update: nvm you actually opened the same PR
Provide environment information
turbo dev
Describe the bug
inside a client component:
import { schema } from "@acme/db"
Seems to load the whole index.ts and so return env error as env can't be use in client.
Link to reproduction
-
To reproduce
import {schema} from "@acme/db"
schema.post.status.enumValues.map((status) => ({ // do somthing with it
Additional information
No response