简体   繁体   中英

Strongloop Loopback: where filter with two arrays

I want to add a where filter in strongloop / loopback which compares two different arrays.

I have the following model:

"properties": {
  ...
  "audience": {
    "type": [
      "string"
    ],
  ...  
}

I want to create a where clause which returns all items where at least one element from 'audience' matches at least one element of another array.

Examples with "audience": ["A", "B", "C"]

  • "anotherArray": ["A", "Z"] => should match!
  • "anotherArray": ["A", "B"] => should match!
  • "anotherArray": ["B"] => should match!
  • "anotherArray": ["Z", "Y"] => should not match!
  • "anotherArray": ["Z"] => should not match!

The filter {where: { audience: { inq: anotherArray}}}; does not seem to do the trick...

This doesn't work if the string values are ids. See comment of Ebrahim Pasbani above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM