Marcel Overdijk
Explore posts from serversDTDrizzle Team
•Created by Marcel Overdijk on 9/9/2024 in #help
creating a join for re-use
Drizzle support creating re-usable where and order by expressions like:
gt(customerTable.salary, 5000);
desc(customerTable.salary)
for this no query builder (qb
) is needed.
is something similar available (without the need of a qb
) to create joins (and apply them later)?
and then later do something like:
for where
and orderBy
this is already possible, but for joins I could't find anything.
my use case is that I'm doing some dynamic stuff.
for now I created my own wrapper like:
and I'm doing something like:
Note what I'm doing is quite dyamic, so having a re-usable withCountryJoin(qb)
won't help me unfortunately.1 replies
DTDrizzle Team
•Created by Marcel Overdijk on 9/1/2024 in #help
Using `$dynamic()` to enhance where clause
I have a function like:
export const applyFilter = (qb: SQLiteSelect, paging: Paging, filter: string | undefined) => { .. }
which adds limit
and offset
and also where
using qb.where(..)
.
This works great, but now I have the use case the qb
received already contains a where clause.
But the qb.where(..)
overwrites it unfortunately.
Is there a way to merge them instead, if the qb
already has a where?22 replies
DTDrizzle Team
•Created by Marcel Overdijk on 8/26/2024 in #help
[sqlite] How to order by rowid?
Having a query like:
I would like to order by the sqlite rowid.
Maybe in this example it would make more sense to order by the country name, but this just for an example.
In my case I have no natural column to order by, but want to sort on rowid.
4 replies
DTDrizzle Team
•Created by Marcel Overdijk on 7/31/2024 in #help
Dynamically adding joins based on relation?
I have this setup:
I can easily refer to columns within the
circuit
table like circuitTable.name
or circuitTable.placeName
.
Can I also refer to relations to dynamically add a join?
E.g.:
and then based on user input I want to add some joins dynamically.
E.g. the user input could be sort on placeName
or country.name
, and in the latter case I want to add the country join.
As I have this in many places I would like to do something smart like:
based on such configs I wanted to apply the sort based on user input sort
field.
Would something like that be possible?7 replies
DTDrizzle Team
•Created by Marcel Overdijk on 7/8/2024 in #help
Typesafe where? argument possible?
I have a service class containing:
now I want to add a
where?
argument to this findAll
function.
Is there a type I can use from Drizzle to make this where?
arg it typesafe?8 replies