如何使用Compass MongoDB中的关键通配符从嵌套对象中找到值?
我在 Compass MongoDB 中有一个嵌套对象:
{
"data_rm": {
"pembiayaan": {
"name": "pembiayaan",
"value": "asuransi",
"type": "radio",
"title": ""
},
"asuransi": {
"name": "asuransi",
"value": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"type": "select-one",
"text": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"title": ""
},
"informasi_diperoleh_dari": {
"name": "informasi_diperoleh_dari",
"value": "pasien",
"type": "radio",
"title": ""
},
"cara_datang": {
"name": "cara_datang",
"value": "sendiri",
"type": "radio",
"title": ""
},
"nama_pengantar": {
"name": "nama_pengantar",
"value": "Tn. BAGUS",
"type": "text",
"title": ""
},
"no_telp_pengantar": {
"name": "no_telp_pengantar",
"value": "0813xxxxxxxx",
"type": "text",
"title": ""
}
}
我如何返回类型为“select-one”的文档? (我想找到 data_rm 中哪个键具有 select-one 类型)
** 编辑 **
所需的输出是:
{
data_rm: {
"asuransi": {
"name": "asuransi",
"value": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"type": "select-one",
"text": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"title": ""
}
}
}
I have one nested object in Compass MongoDB:
{
"data_rm": {
"pembiayaan": {
"name": "pembiayaan",
"value": "asuransi",
"type": "radio",
"title": ""
},
"asuransi": {
"name": "asuransi",
"value": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"type": "select-one",
"text": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"title": ""
},
"informasi_diperoleh_dari": {
"name": "informasi_diperoleh_dari",
"value": "pasien",
"type": "radio",
"title": ""
},
"cara_datang": {
"name": "cara_datang",
"value": "sendiri",
"type": "radio",
"title": ""
},
"nama_pengantar": {
"name": "nama_pengantar",
"value": "Tn. BAGUS",
"type": "text",
"title": ""
},
"no_telp_pengantar": {
"name": "no_telp_pengantar",
"value": "0813xxxxxxxx",
"type": "text",
"title": ""
}
}
How did I return the document WHERE type is "select-one"? (I want to find which key in data_rm has the type of select-one)
** EDIT **
The desired output is:
{
data_rm: {
"asuransi": {
"name": "asuransi",
"value": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"type": "select-one",
"text": "ADMEDIKA - FWD LIFE INDONESIA (FINANSIAL WIRAMITRA DANADYAKSA, PT)",
"title": ""
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您可以做到的一种方法。在 Compass 中,您可以输入聚合管道的每个阶段。
在 mongoplayground.net 上尝试一下。
Here's one way you could do it. In Compass you can enter each stage of the aggregation pipeline.
Try it on mongoplayground.net.