php - How to conditionally find items by Tag in mongodb -


i new nosql , mongodb , little puzzled on type of queries can , how them. knowledge limited simpler queries

i make think complicated query within mongodb instead of using php sort not know if possible or how it.

i have tag field within collection array. {tag: ["blue","red","yellow","green","violet"]}.

first level problem: let says want find birds have tag blue & yellow & green, blue must have tag , other colours optional.

second level problem: order query birds have queried colours appear first.

is possible create query in mongodb? , if how it?

enter image description here

most of have in application. in order find documents bird has tag "blue", can this:

db.collection.find( { tag: "blue" } ); 

which colours optional doesn't matter, have find required tag anyway.

after finding them, need sort. sorting want (by 3 colours) not can in mongodb, , have in php instead.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -