Sunday, 4 June 2017

How do I extract a value from the collection in mongodb [duplicate]

This question already has an answer here:

Let us consider a collection as follow

{ "_id" : ObjectId("123456778"), "title": "temp", "tags": ["pizza", "burger", "fries"]}
{ "_id" : ObjectId("123456765"), "title": "temp2", "tags": ["pancake", "morePizza", "morefries"]}

What would be the query that lets me extract the word pizza and morePizza from the collection above.

I just want these words not the entire data.

--> So if i search of "zz", the query should return "pizza" and "morePizza".

{"tags": ["pizza", "burger", "fries"]},
{"tags": ["pancake", "morePizza", "morefries"]}



via Chetan

No comments:

Post a Comment