Implement SQL and/or
This commit is contained in:
parent
47de3f0c53
commit
2e23a0e4ce
|
@ -369,6 +369,25 @@ class InternalBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
if (filters.$and) {
|
||||
iterate(filters.$and, (key: string, conditions: any[]) => {
|
||||
query = query.where(x => {
|
||||
for (const condition of conditions) {
|
||||
x = this.addFilters(x, condition, table, opts)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (filters.$or) {
|
||||
const { $or } = filters
|
||||
query = query.where(x => {
|
||||
for (const condition of $or.conditions) {
|
||||
x = this.addFilters(x, { ...condition, allOr: true }, table, opts)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (filters.oneOf) {
|
||||
const fnc = allOr ? "orWhereIn" : "whereIn"
|
||||
iterate(
|
||||
|
|
|
@ -2807,7 +2807,7 @@ describe.each([
|
|||
$or: {
|
||||
conditions: [
|
||||
{ range: { age: { low: 1, high: 9 } } },
|
||||
{ string: { name: "Ja" } },
|
||||
{ string: { name: "Jan" } },
|
||||
],
|
||||
},
|
||||
}).toContainExactly([
|
||||
|
|
Loading…
Reference in New Issue