balderdashy / waterline-docs

WARNING: The content in this repo is out of date! See https://github.com/balderdashy/sails-docs for the most up-to-date documentation
452 stars 163 forks source link

`and` and `or` in query language can't express certain combinations #141

Closed tdanecker closed 7 years ago

tdanecker commented 7 years ago

Hi,

I have a condition that looks like (A or B) and (C or D). How can I write this using the waterline query language?

The following doesn't work, unfortunatly:

model.find({
  or: {
    a: ...,
    b: ...
  },
  or: {
    c: ...,
    d: ...
  }
})
particlebanana commented 7 years ago

In the latest beta of Waterline 0.13 this is fully supported syntax:

model.find({
  and: [
    { 
        or: [
            { a: 'a' },
            { b: 'b'}
        ]
    },
    { 
        or: [
            { c: 'c' },
            { d: 'd'}
        ]
    }
})