mongodb - How to get critarea result with specific key and value from collection of mongo database? -


lets suppose, have collection called posts

{ "_id": objectid("5146bb52d8524270060001f3"), "post_text":"this sample post" , "user_name": "mark", "post_privacy": "public", "post_likes_count": 0 } 

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

query is: select post_likes_count posts user_name="mark"; how can same result in mongodb?

ans:

db.posts.find({user_name:"mark"},{post_likes_count,_id:0}).pretty(); 

note mongodb default returns _id field each find statement. if not want field in our result set, have specify _id key 0 value in list of columns retrieved. 0 value of key indicates want exclude field result set


Comments

Popular posts from this blog

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -