Discussion:
[mongodb-user] Help needed to build the query.
DHAVAL JAISWAL
2018-12-04 11:31:49 UTC
Permalink
School Collection and it has two column class is string and name is array

class : 1 -- String
name: { John, Ricky, Vicky} . -- Array

class: 2
name: { Iian, Russel, Chris }

class: 3
name: { Rosy, Ram, John }


Now, I want to build the query on the following scenario.

1. Find all the classes, whose names available in my list.

e.g. if i have a list of { John, Rosy, Ram, Ricky, Vicky, Iian }

It should give me in result class 1 & 3. Since names are available in my
list.

For this i build { name: { $all: [" John", "Rosy","Ram", "Ricky","Vicky",
"Iian"] } on compass but not working and not showing any result.


2. Find John's class, where remaining all names are present in my list.

e.g. if I have a list of John, Rosy, Ram, Ricky

query should give me result as class 3 as rest all name in class 3 is
available in my list.


3. Find all class where only 1 student name is missing in my list and what
is that student name.

e.g. if i have a list of { Russel, Chris, Rosy, John }

query should give me result as class 2 and 3, because from each class only
one name is missing in my list and it should give me student name which is
missing in the list. e.g. class 2 it is Iian and class 3 it is Ram.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAH5ShBi0GXv6ne6t-8KqB9q4zAqjLWQYgLdrOS4cZS2UUkhfqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...