Sunday, 4 June 2017

How do I extract a value from the collection in mongodb if it matches a word i input even partially

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 "Piz", the query should return "pizza" and "morePizza".



via C. Parakh

No comments:

Post a Comment