0

In pseudo code, it'd be as so

Find all businesses where the outcodes array contains NG1

I'm having a hard time finding something that works, and waterline throws it's Invalid usage at everything I try.

  Business.find({
    or:{outcodes: {contains: 'NG1 4RQ' }}
  })

For reference, my business model contains outcodes as an array:

  outcodes:       { type: 'array' },

Is anyone able to advise how I can achieve this. I'm stumped. Currently using SailsJS with Waterline ORM

K20GH
  • 6,032
  • 20
  • 78
  • 118

1 Answers1

0

The or is not working because it needs to be an array. With only 1 criteria, you don't need to use or, but here's an example using or and searching an array for a partial string.

Business.find({
  or: [ { outcodes: { contains: 'NG1' }}]
}).exec(function(err, businesses){...});
noah-sd
  • 186
  • 7