问题
I use Loopback with node to query MongoDB via ngresource of AngularJS.
I wish to implement autocomplete.
Product is my ngResource
Product.find({filter:{where:{name:'search string'}, limit:10}})
The above code only search for 'search string' (Not all matching elements) Like
'search string2'
'search string1'
'search string3'
How to search equivalent to mongoDB's
db.Product.find({name:/.*search string*/});
回答1:
You need to use the like operator in your query filter object :
{filter:
where: {myField: {like: '.*search string.*'}}
}
And that will do the trick.
来源:https://stackoverflow.com/questions/28447838/like-operator-in-ngresource-of-angularjs