【问题标题】:MongoDB how to query a collection with array inside phpMongoDB如何在php中使用数组查询集合
【发布时间】:2018-03-10 06:19:19
【问题描述】:

如何查询带有数组的 MongoDB。

[{
    "issuer":"34a8c528-11f9-490c-82ef-db94808ba4d8",
    "dateAdded":1520547942137,
    "duration":2147483647,
    "reason":".",
    "active":false,
    "rank":"5569543b-efc4-4acf-b6b2-cafd3663b806",
    "rankName":"Owner"
},{
    "issuer":"34a8c528-11f9-490c-82ef-db94808ba4d8",
    "dateAdded":1520556569443,
    "duration":2147483647,
    "reason":".",
    "active":true,
    "rank":"5569543b-efc4-4acf-b6b2-cafd3663b806",
    "rankName":"Owner"
}]

我试过了:

$result = $collection->find(array("groups.rankName" => "Owner"));

但它什么也不返回。有什么想法吗?

【问题讨论】:

    标签: php mongodb mongodb-query


    【解决方案1】:

    $result = $collection->find(array("rankName" => "Owner")); 怎么样? 通过添加 groups,您正在积极搜索具有该属性的对象,尽管我理解您的意思是包含您的 rankName 属性的整个对象。

    【讨论】:

    • 它存储在组列
    猜你喜欢
    • 2023-03-18
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    相关资源
    最近更新 更多