Mongo Find() function won't exclude _id

后端 未结 2 1630
Happy的楠姐
Happy的楠姐 2020-12-11 19:44

Hello I can\'t seem to get the exclude _id to work, here is the code

const findLabels = (db, cb) => {
  // Get the documents collection
  const collection         


        
2条回答
  •  时光取名叫无心
    2020-12-11 20:17

    if you use findOne,

    you can try

        const posts : Collection= db.collection('posts')
        let document = await posts.findOne({
                path: path
            }, {
                fields: {
                    _id: 0
            }
        })
    

    In example, I query path(used as _id)

提交回复
热议问题