db.collection(...).findOne(...).project is not a function

Views: 61 Ask New Question


getting following error with NodeJS MongoDB driver

db.collection(...).findOne(...).project is not a function
On By

1 Answer


.project you can use on find. when you are using it for findOne use it like following

db.collection('foo').findOne({foo: bar}, {projection: {_id: 1, foo: 1}})
On By


Answer This Question