I am new to NoSQL
and MongoDB
and I am a little puzzled on what type of queries I can do and how to do them. my knowledge is limited to simpler queries
I would like to make what I think its a complicated query within MongoDB
instead of using PHP
to sort it but I do not know if it is possible or how to do it.
I have a tag
field within my collection that is an array
. {tag: ["blue","red","yellow","green","violet"]}
.
First level problem: Let says I want to find all birds
that have the tag
blue & yellow & green
, where blue
is a must have tag
and any other colours are optional.
Second level problem: Then I would like to order the query so that the birds
that have all the queried colours appear first.
Is it possible to create this query in mongoDB? and if it is How could I do it?