like operator in ngresource of angularjs

怎甘沉沦 提交于 2019-12-12 05:28:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!