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?

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
Post a Comment