0

Country data looks like -

[{
   inEU : true,
   x    : {...},
   y    : {...}
}
{
   inEU : false,
   x    : {...},
   y    : {...}
}]

I need to choose either x or y object based on inEU field is set to true or false. X and Y object have the same keys (values/data is different).

Find query must use values from X if inEU is true else use Y object for search purpose.

Kindly let me know if its possible and if yes do provide any URL/links of documentation or any small example will help me.

Manthan
  • 193
  • 1
  • 1
  • 14

1 Answers1

0

You can use $or to do that. For example:

Model.find( { $or: [ { inEU: true, x: condition }, { inEU: false, y: condition } ] } )...
Cuong Le Ngoc
  • 11,595
  • 2
  • 17
  • 39