【问题标题】:Query a nested dictionnary in MongoDB document在 MongoDB 文档中查询嵌套字典
【发布时间】:2021-01-06 13:23:47
【问题描述】:

我正在尝试学习如何过滤掉 MongoDB 数据库中的嵌套字典。所有文档都具有与此示例相同的结构,我将尝试获取:

感谢Name,即“My Burberry - Eau de Parfum”,我尝试获取该文件:

{ "q0.Results": {"Name":"My Burberry - Eau de Parfum"} }

但它并没有给我任何回报:

【问题讨论】:

  • 你可以试试{ "q0.Results.Name": "My Burberry - Eau de Parfum" }

标签: arrays database mongodb multidimensional-array mongodb-query


【解决方案1】:

你在做什么:

{ "q0.Results": {"Name":"My Burberry - Eau de Parfum"} }

说找到我的文档,其中q0.Results 与此文档/子文档完全相同:{"Name":"My Burberry - Eau de Parfum"}

在数组中,您只需要点表示法,以下应该会给您结果:

{ "q0.Results.Name": "My Burberry - Eau de Parfum" }

【讨论】:

    猜你喜欢
    • 2018-03-09
    • 2021-02-25
    • 2016-08-16
    • 2023-03-08
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多