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
need advice how to configure driver to return prefixed or drizzle style selections
Ideally I would like to get shape with a query like drizzle offers, meaning each table has its own object (eg. products joined with tax would return multiple rows as {product:{}, tax:{}}) or at least add a prefix to the columns. From what I read yesterday, this is beyond the scope of kysely, and more of a db driver task. Has anyone done something similar in combination with kysely and could give me a hint, because I don't really know how to go about it. Thanks!
5 replies
problem with nested jsonArrayFrom and jsonObjectFrom
Typescript raise error when attempt to reference to relations in nested json helpers is made. Is this syntax error or kysely limitation?
https://kyse.link/SL7ct
4 replies
Is there way to select every field from table using `select` instead of `selectAll`?
I have very wide table and writing every field by hand is time consuming.
selectAll
does the job, but I also need to populate some relations and build json_agg
s. Is there way to either select every column from table (and then build jsonObject) or extend selectAll
with some extra fields?
Using raw sql it could be done with please dont waste your time on building this query, just a little hint will be super helpfull! 😉4 replies
How to delete and insert in one query
Hey! I wonder how with kysely make for example delete and insert in one query to reduce db roundtrips.
I believe Using WITH Clause (Common Table Expressions - CTEs) might help, but how kysely syntax would looks like?
Should I simply use raw sql here?
6 replies
json object relation null problem
I am trying to make https://kysely.dev/docs/recipes/relations this helper work, but get error
I wrote code following docs example:
usage:
and helper expression?:
adding union with
null
here:
fixes problem, but it looks like it should work without null
after adding .$notNull()
as above and later after select any clue?6 replies
How to narrow type from jsonArrayFrom
Hey! I need to narrow some types from table that works as
Single Table Inheritance
table. I believe this is possible, but after some fighting with api and syntax I am not sure how to make it.
Here is my query:
(sorry for polish, Ubiquitous Language with domain masters)
6 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
Is it possible to change type of returned value with jsonBuildObject?
I struggle typing reponse schema in fastify cuz query returns
'wartosc'
as string
but actually it returns number
. Can't simply change zod reponse schema, cuz kysely types wartosc
in query is as string, and there is type mismatch anyway. (sorry for polish, ubiquitous language with polish domain masters)
is something like this possible (simmillar to type casting with raw sql sql<number>
? if not any tip how to handle this?
I would really like to put data in proper shape in sql to avoid extra mapping on backend code16 replies
Is it possible to configure to which types database columns are introspected?
We use kysely-codegen and we would like to use those generated types, but they ofter are translated to diffrent types we want. Lets say
int id
is introspected to Generated<number>
(we would like number type) or decimals
are introspected to Numeric
(we would like just number)6 replies
ASP.NET Core Identity - How to manage roles?
HEY! I'm starting with asp.net and can't figure out a certain thing. I want to implement authentication and authorization (RBAC) to rest api. From what I can see this is what 'Identity' is used for, right? While authentication seems straight forward, I don't completely understand how roles should be managed. Do you create CRUD endpoints yourself to manage them?
2 replies
PPrisma
•Created by tzezar on 5/15/2024 in #help-and-questions
Does prisma allow use of Shared Primary Key?
if so, what should the model look like? Sorry if this has already been asked somewhere, I can't find anything.
2 replies