How to query documents containing lists

0 votes
Hi,

I am storing JSOn documents that contain lists. Something like this, for instance :

{ names : [ "bob", "mark", "joe" ], otherParam1: "true",  otherParam2: "12345" }

 

How can I build a query to retrieve all documents that have the list "names" that contain given name (for instance "joe") ?

Thanks for the help!
asked Dec 1, 2015 in App42 Cloud API-BaaS by dujardin (10 points)

1 Answer

+1 vote

Hello,

In order to answer your query of finding a list of documents which contains key as names is very simple. You just need to build a query as stated below:

 
Query q1 = QueryBuilder.Build("names", "joe", Operator.EQUALS); 
 

Regards,

Himanshu Sharma

answered Dec 2, 2015 by hs00105 (2,005 points)
edited Dec 3, 2015 by hs00105
Hello,

Thanks for the reply. The use case is the following: a user is opening a room in AppWarp and inviting a list of other users. Users are on pc, so as far as I know there is no notification system that we can use. The user is storing a document with room id and list of invited users.
I want other users to be able to check the storage service to see if they are in an invited list, and if so, to retrieve the room id in order to join the room.
Hello,

I have updated my answer, please check and let us know if you need any help from my side.

Regards,
Himanshu Sharma
Hi
Reverse is possible ? like
{ names :"ram", otherParam1: "true",  otherParam2: "12345" }
 Query q1 = QueryBuilder.Build("names", "joe,sam,ram", Operator.EQUALS);
Hi Venkat,

You can send array of usernames in the value and use inlist operator to get the result. Please have a look into it and let me know if it helps.

Regards,
Himanshu Sharma
Thanks for reply. I used inlist operator, its working well.What are all such type operators those we can use?.


Regards,
Venkat
Please find below list of operators which may help to find the documents from the collection:

EQUALS ,NOT_EQUALS ,GREATER_THAN ,LESS_THAN,GREATER_THAN_EQUALTO ,LESS_THAN_EQUALTO,LIKE ,AND ,OR ,INLIST  

Regards,
Himanshu Sharma
Thanks Himanshu
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...