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

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -