skip to Main Content

my code is :

result = await mongoDBO.collection(collectionName).find({id: data.id},{projection : {'_id' : 0}}).toArray();

But I get the following error

Unsupported projection option: projection: { _id: 0 }

2

Answers


  1. Chosen as BEST ANSWER

    I also tested this way and it worked

    await mongoDBO.collection(collectionName).find({id:data.id}).project({'_id' : 0}).toArray()
    

  2. Remove projection property. Just send the projection object:

    result = await mongoDBO.collection(collectionName).find({ id: data.id }, { '_id': 0 }).toArray();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search