mongodb - MongoDB 嵌套对象
问题描述
我需要帮助。最近开始教mongodb。我不知道如何访问嵌套项目。请帮忙:我怎样才能找到“职业”的钥匙?
{
"_id" : ObjectId("60a4bbd1753b2bb53e6f7dba"),
"name" : "Bob",
"class" : 7.0,
"lessons" : [
"english",
"mathematics"
],
"avgScore" : 3.5,
"parents" : [
{
"gender" : "female",
"name" : "Ira"
},
{
"gender" : "male",
"name" : "Dima",
"profession" : "programmer"
}
]
}
解决方案
我认为您需要使用elemMatch
ElemMatch
推荐阅读
- python - 当按钮触发kivy中的功能时代码崩溃
- javascript - JavaScript json 操作问题
- java - Java中的计时方法产生不正确的值?
- anaconda - Spyder 4.01 和 plotly 4.5.1 - Anaconda 尝试降级 Spyder
- php - PHP 代码提交检查逻辑错误并创建重复条目
- ms-access - 将 ComboBox 选项连接到文本框中
- git - git中的合并冲突到底是什么?
- c - 从软盘图像中读取扇区 - 位移?
- python - 熊猫数据框如何将对象转换为数组并提取数组值
- java - 将数组读/写到firebase的最佳/更好的方法