0

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)

2 Answers 2

0

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

You may create inq item like this:

let itemNames = [new RegExp('/test/i'), new RegExp('/test2/i')];

It worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.