1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00

Implement SQL and/or

This commit is contained in:
Adria Navarro 2024-08-05 12:33:44 +02:00
parent 47de3f0c53
commit 2e23a0e4ce
2 changed files with 20 additions and 1 deletions

View file

@ -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(

View file

@ -2807,7 +2807,7 @@ describe.each([
$or: {
conditions: [
{ range: { age: { low: 1, high: 9 } } },
{ string: { name: "Ja" } },
{ string: { name: "Jan" } },
],
},
}).toContainExactly([