enumerating tables
I have a table of possible 'statuses' for a column in my records table and would like my zod schema to see what statuses are available to set. Is this possible? I'm aware we can create an ENUM column on my records, but it 'feels' better to have a separate table for this.
I guess I'm looking for an 'in-between' an enum column and a separate table. Maybe it's possible to predefine/lock-in the statuses in the application layer, is it bad practise?
I'm new to db stuff so unsure on the best approach.
Angelelz•193d ago
You could store the
statusId
on your records table that points to the status table where the statuses are.
But if the statuses don't have any other meta information on them, I think an enum would be betterJim•193d ago
Thanks! I've not used the enum column before so wary of using it. I'll give it a go. I was about to go the tables way and make a script which would validate the database prebuild. This would be a headache tbh so thanks for nudging me to the enums, fingers crossed.
Angelelz•193d ago
It's great IMO, you'll have autocomplete on the statuses
Jim•193d ago
yeah it's exactly what i need 😂
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
7.4KMembers
View on DiscordWant results from more Discord servers?
More Postshow to group Related Items```typescript
// index.ts
const coursesList = await db
.select({ title: courses.title, tags: tagsNested where filter, how to not include emptyThe following almost works
```
const query = db.query.productionItem.findMany({
with: {
itemStis placeholder in prepare statements deprecated!??```typescript
const courses = db.query.userCourses
.findMany({
where: eq(placeholder("userId")SQLite json_eachHi. I wandted to use the json_each function in sqlite, but I dont think the query is building correcForeign key truncated for being too long?Hi,
I have multiple warnings / notices:
`{
severity_local: 'NOTICE',
severity: 'NOTICE',
codedrizzle-zod with custom typesI have defined opaque types in my application and have implemented those in the drizzle schema (awesUsing transactions in automated testing like JestI have a testing set-up as follows:
1. Start postgres container
2. Apply migrations to db
3. Jest tTypeScript complaining about using a spread operator in partial select queryTypeScript complaining about me using a spread operator in partial select query.
I have the followiUnable to read error message when inserting withdb.insert().values()Hey there, i am using visual studio code and am developing with nuxt3. I am trying to insert an objehow to add new driver to drizzle?what is the procedure of adding a new driver to drizzle orm?`drizzle-kit --custom` is not giving me a blank migration fileI'm doing the following:
```sh
drizzle-kit generate:pg --custom
```
But it's not giving me a blankNo id returned (mysql2)```
async function create(data: NewBusiness) {
return client.insert(business).values(data)
}
```