-1

Lets suppose, we have collection called posts

    {
    "_id": ObjectId("5146bb52d8524270060001f3"),
    "post_text":"This is a sample post" ,
    "user_name": "mark",
    "post_privacy": "public",
    "post_likes_count": 0
    },
   {
    "_id": ObjectId("5146bb52d8524270060001f4"),
    "post_text": "This is a sample post",
    "user_name": "pramod",
    "post_privacy": "public",
    "post_likes_count": 0
   }

lets assume we have same table in mysql. I want same query of sql result into mongo.

query is: select post_likes_count from posts where user_name="mark"; How we can get same result in mongodb?

Pramod Kharade
  • 2,005
  • 1
  • 22
  • 41
  • 1
    Possible duplicate of [How to select a single field in MongoDB?](http://stackoverflow.com/questions/25589113/how-to-select-a-single-field-in-mongodb) – styvane Jul 12 '16 at 12:54

1 Answers1

-1

Ans:

db.posts.find({user_name:"mark"});

mongo playground

Pramod Kharade
  • 2,005
  • 1
  • 22
  • 41