Find nested array-object from rethinkdb in feathers JS

北城以北 提交于 2019-12-10 16:56:42

问题


I have a data set like follows-

[{

    "allowedusers": ["paul@abc.com"],
    "id": "1"

  },{

    "allowedusers": ["kmahera@abc.com","rbajaniya@abc.com"],
    "id": "2"
   },{

    "allowedusers": ["whatever@abc.com","rbajaniya@abc.com"],
   "id": "3"
}]

and I have a Query like this -

http://localhost:3030/flowz$limit=5&allowedusers[$in[]=rbajaniya@abc.com&$skip=0&$select[]=id&$select[]=alloweduser.

But I am not getting all the objects that contain rbajaniya@abc.com . How can I craft my query to get this. I want to get id=2 and id=3 in response .


回答1:


$in is to check a single value in the database against a list of possible values. What you are looking for is the other way around which can be done through the feathers-rethinkdb specific $contains operator:

http://localhost:3030/flowz?$limit=5&allowedusers[$contains]=rbajaniya@abc.com&$skip=0&$select[]=id&$select[]=alloweduser


来源:https://stackoverflow.com/questions/48782202/find-nested-array-object-from-rethinkdb-in-feathers-js

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