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


getting following error with NodeJS MongoDB driver

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

1 Answer

5 years ago by

.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}})
5 years ago by Karthik Divi