How to return only value of a field in mongodb

后端 未结 4 1731
别跟我提以往
别跟我提以往 2020-12-17 17:48

After applying the find operation in mongodb.. i get the following list of documents..

  db.users.find(....)

i got:

 { \"t         


        
4条回答
  •  甜味超标
    2020-12-17 18:19

    Not sure what you language implementation is but the basic concept is:

    var result = []
    db.users.find().forEach(function(u) { result.push(u.text) })
    

    And the returned value to result is:

    ["Hey","Hi","Hello","yes"]
    

提交回复
热议问题