piechart
piechart
DTDrizzle Team
Created by jacob.pastorek on 5/16/2024 in #help
Select in nested findMany query ?
It will be possible in relational API v2. For now you have to process the result in application code, something like result.items.map(item => item.items)
3 replies
DTDrizzle Team
Created by textYash on 4/1/2024 in #help
How to search the docs for the correct datatype returned by each function?
I think it will be the error thrown by the underlying client. So it depends on the client you are using
4 replies
DTDrizzle Team
Created by cssetian on 3/8/2024 in #help
Trouble using findMany with joined relation and where clause on relation
Yes it's possible with a many() relation. But it only filters the related comments, not the posts at the top level. So it's not the same behavior as the one you were looking for with the join.
8 replies
DTDrizzle Team
Created by Icemourne on 3/8/2024 in #help
How can I make reusable columns then building schema?
Make username a function instead of a variable
3 replies
DTDrizzle Team
Created by laf_RSW on 3/8/2024 in #help
Trouble with tablesFilter
Try a single filter of the form !@(spatial_ref_sys|geometry_columns) Or you could also put those tables in a separate schema and use schemaFilter
7 replies
DTDrizzle Team
Created by JiinX on 3/5/2024 in #help
Setting up relations on signin
The portal = await db.insert() call does not return the inserted row. You need to use db.insert().returning() if your db engine supports it or fetch the portal after inserting it
2 replies
DTDrizzle Team
Created by Richard E on 3/7/2024 in #help
Is there a way to set foreign key on a bulk insert?
Each drizzle call represents one SQL query and you need one insert per table, so I don't think you can do this in a single call. The way you're doing it seems optimal to me, and looping through the array to set the master id can be done quite concisely in js
2 replies
DTDrizzle Team
Created by ewert on 3/6/2024 in #help
Drizzle multi databse config (MySQL)
For drizzle-orm you'd have to instantiate two separate db objects and pass the correct db object as an argument to your functions if you want to reuse the same query logic. For drizzle-kit it should be possible too, with separate schemas and two separate config.ts files. You can specify the one to use with each command with --config
3 replies
DTDrizzle Team
Created by Zeraph on 3/7/2024 in #help
Why fields with default value is nullable
You have to mark the column as NOT NULL. The default value is inserted if no value is provided, but you can still explicitly set a NULL value.
3 replies
DTDrizzle Team
Created by cssetian on 3/8/2024 in #help
Trouble using findMany with joined relation and where clause on relation
This is only valid if the relation is defined with many(), i.e. there are many related rows in tableTwo for each row in tableOne and you want to only return some of them. If the relation is one-to-one the nested "where" does not make sense. Your options are: 1) custom "where" condition at the top level with raw sql, something like exists (select * from tableTwo where joinColumn = ${tableOne.joinColumn} and organizationId = ${organizationId}) 2) rewrite as an innerJoin without query API 3) filter the result in javascript instead
8 replies
DTDrizzle Team
Created by kbemaster on 2/26/2024 in #help
Shouldn't the fields related to the Query API be of type <T | undefined> ?
As far as I can tell, the type of the relation field is nullable when the foreign key column is nullable in the schema (so may not always exist), and non-nullable if the foreign key always exists.
6 replies