之后如何获得猫鼬文件的财产?

问题描述

我尝试检索/填充已经存在的猫鼬文档的属性?

我不想在初始查找查询中投影键,因为我仅在1%的呼叫中使用该属性...

有什么主意吗?看来填充仅适用于交叉收藏夹引用。

非常感谢!

解决方法

如果我理解正确,您是否想使用猫鼬ORM在MongoDB(我想是?)数据库中检索文档?

一些功能:

your_mongoose_schema.findOne({your_column: "column1"},function(err,doc) {
  //return the first document that have column1 for your_column attributes
 // doc.your_column = "column1"
})
your_mongoose_schema.find({your_column: "column1"},docs) {
  //docs = array with all the docs that have "column1" for your_column attributes 
})

如果要检索不带_id属性的文档:

your_mongoose_schema.find({your_column: "column1"},{ '_id': 0,'column1' :1},doc){

}); 

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...