簡體   English   中英

如何從mongo數據庫的集合中獲取具有特定鍵和值的critarea結果?

[英]How to get critarea result with specific key and value from collection of mongo database?

讓我們假設,我們有一個名為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
   }

讓我們假設我們在 mysql 中有相同的表。 我想對 mongo 的 sql 結果進行相同的查詢。

查詢是: select post_likes_count from posts where user_name="mark"; 我們如何在 mongodb 中獲得相同的結果?

答:

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

蒙戈游樂場

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM