You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified this feature I'm about to request hasn't been suggested before.
(closed one, and related ones but not that complete)
Describe the enhancement you want to request
Hey,
This is a reopening of dynamic selection topic, with a pretty decent use-case I believe.
I'm making yet another one full featured REST API, which always take the same query parameters
{
filter: // some filtering expressionsortBy: // some sorting expression
}
{
items: // data array,pagination: {take: number,skip: number,total: // the total count of unpaginated items
}
}
This inevitably and systematically leads to 2 queries which are almost the same, but not exactly :
constitems=awaitdrizzle..with(/* some CTES */).select()// select * from all tables.from(a).join(b,eq(a.id,b.a_id).where(where)// filtering.limit(query.take)// pagination.offset(query.skip)// pagination.orderBy(...sortBy)// ordering.execute()constcount=awaitdrizzle..with(/* some CTES */).select({count: count(a.id)})// select the count.from(a).join(b,eq(a.id,b.a_id).where(where)// filtering// no pagination and ordering.execute()
From there we can observe all of the :
with CTEs
from
join
where
are common to both queries
From many attempts, and readings (#948, #2954, #1817), I'm struggling at factorizing all the common parts.
More specifically :
I managed to factorize the .with CTEs basically like so :
Is there any known strategy to achieve the same thing with Drizzle, or any consideration to be able to build a dynamic select or even moving the select at the end of the statement ?
The text was updated successfully, but these errors were encountered:
Feature hasn't been suggested before.
(closed one, and related ones but not that complete)
Describe the enhancement you want to request
Hey,
This is a reopening of dynamic selection topic, with a pretty decent use-case I believe.
I'm making yet another one full featured REST API, which always take the same query parameters
This inevitably and systematically leads to 2 queries which are almost the same, but not exactly :
From there we can observe all of the :
with
CTEsfrom
join
where
are common to both queries
From many attempts, and readings (#948, #2954, #1817), I'm struggling at factorizing all the common parts.
More specifically :
.with
CTEs basically like so :I factorized the
where
by just instanciating aSQL<bool>
producing functionI'm struggling at factorizing the
from
+join
with different.select()
sI'm coming from kysely where I was basically doing :
which were allowing insane modularity like so :
Is there any known strategy to achieve the same thing with Drizzle, or any consideration to be able to build a dynamic
select
or even moving theselect
at the end of the statement ?The text was updated successfully, but these errors were encountered: