mongoose - 猫鼬选择错误
问题描述
我有一个像这样的猫鼬模式
first_name : String,
other_names : String,
last_name : String,
gender : String,
title : String,
employment :{
office : String,
location : String
},
hobbies :[{
hobbied_id : Schema.Types.ObjectId
}],
contact :[{
address : String,
city : String
}]
当我尝试通过我使用的 mongoose 从 mongodb 中提取信息时
Person.find({'exployment.office':'Greenway'})
.exec(function(err, result){
console.log(result);//<- this gives expected result
console.log(result.employment.office);//<- this produces error of undefined
console.log(result.contact.address);//<- this produces error
});
这会产生与在 Greenway 工作的所有人员有关的所有信息。但是当我尝试从结果中获取特定细节时,它会产生未定义的错误,请问我做错了什么,还有任何书籍或网站对学习猫鼬有用
解决方案
推荐阅读
- c - 未知数据类型 IRQn_Type,
- ios - FlutterDriver:Flutter Driver 扩展需要很长时间才能可用
- java - 我可以在 Eclipse 上运行一个打开控制台的程序,然后打开一个处理窗口吗?
- asp.net - ASP.NET MVC 和 II7 的静态重写,为什么所有页面链接都断开?
- sql - JsonSerializationException:无法反序列化当前 JSON 对象。在 asp.net 核心中
- javascript - 使用 css 中的变换或其他一些高性能方式从圆创建长圆形
- html - 使用 svg 每隔几秒移动一次对象
- keras - Keras 示例中的自动编码器
- amazon-web-services - 无法在 AWS 中保存 lambda 处理程序函数
- reactjs - DropDown 没有与 npm run build 一起显示