0

I have a model with these attributes:

  attributes: {
    title: {
        type: 'string'
    },
    tags: {
        type: 'array'
    }
  }

How can I query whether or not the tags attribute contains some value? For example, I would like to select all the records that have the tags blue and green. Is this even possible with Waterline? I couldn't find any documentation regarding this topic.

ChrisU
  • 473
  • 4
  • 14

1 Answers1

1

Waterline doesn't support the array type in this manner. The proper way do check if a record has some values is use an association. See this answer from stack overflow. See Sails documentation on associations: http://sailsjs.org/#/documentation/concepts/ORM/Associations/OnetoMany.html

Community
  • 1
  • 1
ChrisU
  • 473
  • 4
  • 14
  • I encountered a similar scenario where a given model contained the attribute `activities`. An array consisting of only strings. Even worse, `activities` of different instances of the model aren't overlapping. It wouldn't make any sense to create an own model for these `activities`, so using associations is not an real option in this case. Is there another way of querying model instances by whether or an array contains a value? – Lando-L Nov 09 '17 at 23:22