[英]TypeError: Model.find(…).project is not a function
let totalProducts = await RentedProducts.find({
customer: req.params.id,
}).project({ barcodes: 1 })
I just want to fetch the barcodes field but It is giving an error.我只想获取条形码字段,但它给出了错误。
TypeError: RentedProducts.find(...).project is not a function类型错误:RentedProducts.find(...).project 不是 function
I have also installed MongoDB nodejs driver:我还安装了 MongoDB nodejs 驱动程序:
"mongodb": "^3.6.3",
How to use.project() for minimizing the bandwidth by reducing the number of fields on return.如何使用 .project() 通过减少返回的字段数量来最小化带宽。
if you are using simple find command you don't need project:如果您使用的是简单的 find 命令,则不需要项目:
db.RentedProducts.find({customer: req.params.id}, {barcodes: 1, _id: 0 })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.