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
I think the correct way to specify a projection is to use the "fields" or "projection" property, depends on the version of your driver.
collection.find({}, {projection:{ _id: 0 }})
Read documentation here.
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)