tzezar
Explore posts from serversDTDrizzle Team
•Created by tzezar on 8/4/2024 in #help
Is using zod for type narrowing fine solution?
Is using parse for type narrowing good idea with decent performance or should I make validation functions for objects?
2 replies
DTDrizzle Team
•Created by tzezar on 7/9/2024 in #help
How to type connection as conn or transaction?
My attempt was like below:
but passing transaction to function using it raise error. Any idea?
2 replies
DTDrizzle Team
•Created by tzezar on 7/9/2024 in #help
Does 'query' support subqueries with filters?
Is it possible to define subquery with filters for many to one relation?
2 replies
DTDrizzle Team
•Created by tzezar on 7/8/2024 in #help
applying migrations...error: unsafe use of new value "zewnetrzny"
adding model with enum like below (sorry for polish, ubiquitous language with domain masters)
raise error:
"zewnetrzny" is not listed as forbidden word in pg, why error then?
3 replies
DTDrizzle Team
•Created by tzezar on 7/7/2024 in #help
How to narrow type in select from enum?
During select I need to narrow enum type from multiple choices to one choice eg just 'product'
schema
query
result
typ
value is typed as typ: "produkt" | "usluga";
and I need to narrow it to just product
I would be glad for any tip how to accomplish this. Thanks!2 replies
DTDrizzle Team
•Created by tzezar on 4/6/2024 in #help
Default isolation level for transaction
Is it possible to globally set default isolation level?
1 replies
DTDrizzle Team
•Created by tzezar on 3/25/2024 in #help
coalesce
I wonder how to make COALESCE(smth, 0) with drizzle? Postgresql
I need COALESCE(alreadyReleased, 0)
1 replies
DTDrizzle Team
•Created by tzezar on 3/3/2024 in #help
Conditional join
Hey! I am looking for a way of making conditional joins based on some statement. I found only one post in this topic https://discord.com/channels/1043890932593987624/1128636955270324275 that does not help me much.
lets say this is my query:
I need to make joins conditional, because some filters require joins and in other cases I do not need join so its like wasted computation time. So example showing my need:
I would be glad for any tip how to do this.
6 replies
DTDrizzle Team
•Created by tzezar on 2/17/2024 in #help
will joins in delete queries be supported?
example:
2 replies
DTDrizzle Team
•Created by tzezar on 2/1/2024 in #help
How should locks be done with drizzle?
Table or row locks in postgres. How can
select for update
be done in drizzle?5 replies
DTDrizzle Team
•Created by tzezar on 1/26/2024 in #help
Inserting into columns of type Enum
Hi! I am not sure how to insert data into enum column type...
and query:
above code results in ungly error:
Found simmilar topic, but solution with adding cosnt to enum value does not work.
https://discord.com/channels/1043890932593987624/1120919676457848946
7 replies
DTDrizzle Team
•Created by tzezar on 1/25/2024 in #help
Modified select() on an existing query example
Hey, I would like to reuse first query with some left joins etc. to obtain results count with second query
I found some posts, and it seems its possible, but cant get it working.
I just need to alternate select() to other fields, more precisely to a simple sql count expression.
https://discord.com/channels/1043890932593987624/1104858040936706140
https://github.com/drizzle-team/drizzle-orm/issues/561
2 replies
DTDrizzle Team
•Created by tzezar on 1/23/2024 in #help
all table definition type
Hi everyone! Is there possibility to obtain type of all defined models?
I created helper function that takes one particullar
table
as parameter and would love to have it typed.2 replies
DTDrizzle Team
•Created by tzezar on 12/29/2023 in #help
dynamic subquery?
Is it possible to make dynamic subquery? I need to filter subquery by some value and cant figure out how to make it.
13 replies
DTDrizzle Team
•Created by tzezar on 12/21/2023 in #help
how to use types on frontend
Hey guyz, according to: https://discord.com/channels/1043890932593987624/1179496917420490782 it is possible to get types for inserts or reads; thats super dope, but I have a question, I am not sure how to use those types on fronted.
Got two folders, one for backend with expressjs + drizzle and second one for frontend (svelte + sveltekit). How can I import those types?
backend
fronted
8 replies
DTDrizzle Team
•Created by tzezar on 12/3/2023 in #help
circular foreign keys
I have separate files for each table:
but this does not work, error:
How to fix it?
4 replies
DTDrizzle Team
•Created by tzezar on 12/3/2023 in #help
select and alter columns with drizzle-zod
Hi, I want to create validation schema for update patch request. Not sure how it should be done. I want to (based on drizzle schema) select which field is updatable and mark everyfield as optional.
I tried:
this does not work, I must be missing something
4 replies
DTDrizzle Team
•Created by tzezar on 11/29/2023 in #help
Do I have to import table name type for select query?
Doing this simple query:
I get no intelisense with ts etc.
after importing
import { user } from "../../../drizzle/migrations/schema";
it works. This is the way or I messed up configuration?4 replies