Chain multiple where
clauses WITHOUT overriding original 'where'
#2259
Unanswered
outofthisworld
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was wondering if it is possible currently, to somehow chain
where
multiple times, or somehow create a query builder with the result of a previous query.In my API, I'm building functionality that will parse individual queryParams and build a query based on these.
e.g in the the following code the scopes
withResult
,limitBy
andanother
would be invoked if a HTTP request was sent to the API with a URL that looked like/api/someEndpoint?withResult=1&limitBy=10&another=2
.Example scope configuration:
Behind the scenes query could be seeded initially using something like
db.select().from(someModel).$dynamic()
.The problem is with the chaining of
.where()
as the most recent where overrides the previous. I need a way to avoid this behaviour and allowwhere
to concatenate.If I change the scopes so they return something like
and(or(xxx,xxx), xxx)
then I could theoretically dodb.select().from(xxx).where(and(...[scopeResults]))
. The downside being that the scopes cease to works for the like oflimit
orskip
etc.Any thoughts anyone?
Beta Was this translation helpful? Give feedback.
All reactions