Search code examples
loopbackjs

How to query with Loopback JS model string parameter contains in regexp array?


I tried to query Loopback js Model using "inq" (mongo $in) syntax

like this:

let itemNames = [/test/i, /test2/i]; app.models.skill.find({where: {name: {inq: itemNames}}}, ....

But loopback is changing regexp to strings. loopback sends strings like { name: { $in: [ "/test/i", "/test2/i" ] } }

expected to work like described here: https://docs.mongodb.com/manual/reference/operator/query/in/#use-the-in-operator-with-a-regular-expression

Can you suggest a fix or a workaround for this (but I can't patch loopback itself it is a business requirement)


Solution

  • Loopback accepted my changes, https://github.com/strongloop/loopback-datasource-juggler/pull/1279

    so it should be possible to use regexps like in mongo.