logo image

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

1 year 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}})
1 year ago by Megamind