How to select a single field for all documents in a MongoDB collection?

前端 未结 20 1215
执念已碎
执念已碎 2020-11-22 07:58

In my MongoDB, I have a student collection with 10 records having fields name and roll. One record of this collection is:

{
    \"         


        
20条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 08:42

    _id = "123321"; _user = await likes.find({liker_id: _id},{liked_id:"$liked_id"}); ; let suppose you have liker_id and liked_id field in the document so by putting "$liked_id" it will return _id and liked_id only.

提交回复
热议问题