TypeError: .select is not a function

Viewed 37

Recently, I have updated Mongoose from 5.7 to 6.4 and since then I have facing this issue.

 query = await db.DATABASENAME.find(JSON.parse(queryStr)); 

Earlier query.select("-meeting -__v"); query.lean() and some other were working fine. But, after update, I am getting:

"TypeError: query.select is not a function" and same for others.

1 Answers

The error was due to await, it is not returning the query but the object, .select can only be operated on query not the object, so the solution is to remove await.

Related