meteor-autocomplete
meteor-autocomplete copied to clipboard
Issue with selector with regex in return
I have seen a few examples like below:
selector: function(match) {
regex = new RegExp(match, 'i')
return {'profile.firstName': regex}
}
I am actually trying the code above. If I put a string in place of regex
, it is passed and works correctly, but when I use the regex
variable, the output sent to query looks like this 'profile.firstName': {} } { limit: 10, sort: { _id: 1 } }
. Notice the regex
portion is missing.
Anyway, I am not sure why this doesn't work yet. Any thoughts?
Were you able to workaround to this?
I don't think you can use a Javascript regex in a Mongo query that way; you should try the string literal version: https://docs.mongodb.com/manual/reference/operator/query/regex/ . Otherwise, use $regex
.
@mizzao Yes. I did the same. Will share the code in some time to help others who face this issue.
Thanks for responding and making this great package!