nested $and in $or causes Exception in pouchdb-find

Viewed 454

I'm trying to do a simple Query with the pouchdb-find plugin. (Variables are just examples)

let query = {
  selector: {
    $or: [{
        $and: [
          {country_code: 'DE'},
          {zip_code: '47228'}
        ]
      },{
        $and: [
          {country_code: 'UK'},
          {zip_code: '45664'}
        ]
      }
    ]
  }
};

If im trying to nest $and in an $or like this, I'm always getting the following Exception:

Error: unknown operator "0" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all

I did not find any solution to this or similar problems. Is this just not possible? Nesting this the other way around ($or in $and) is working fine.
I just can't get my head around how to query for different Objects with specific sets of Attributes. The only solution I'm seeing at the moment is to do multiple queries.

0 Answers
Related