Chaining/combining $dynamic query functions
Hi everyone -
I'm trying to take advantage of the new dynamic query building feature to simplify the way I query my db for displaying data in a table. I've already implemented a nice helper function to add ORDER BY to a query, e.g:
And now I'd like to do the same for pagination, just like in Drizzle's docs:
What's the cleanest way to use both of these helpers? Nesting them does technically work:
But that seems pretty hard to read and work with. Has anyone figured out a better way? Thank you!
I'm trying to take advantage of the new dynamic query building feature to simplify the way I query my db for displaying data in a table. I've already implemented a nice helper function to add ORDER BY to a query, e.g:
const result = await withOrderBy(qb, {
orderBy: 'name',
order: 'desc'
})And now I'd like to do the same for pagination, just like in Drizzle's docs:
const result = await withPagination(qb, {
page: 2,
pageSize: 10
})What's the cleanest way to use both of these helpers? Nesting them does technically work:
const result = await withPagination(
withOrderBy(qb, {
...args
}),
{page: 2, pageSize: 10}
)
But that seems pretty hard to read and work with. Has anyone figured out a better way? Thank you!