如何获取mongodb集合文档的对象的最后一个属性

时间:2016-11-30 15:16:59

标签: mongodb mongodb-query

我想匹配mongodb集合下对象的最后一个属性。例如,我的收藏下的两个记录列在下面。

{
    "_id" : "5:/content/mac/authujul281469689982632/notifications/node",
    "jcr:primaryType" : {
            "r158b588cae9-0-2" : "\"nam:nt:unstructured\"",
            "r158b588d4ed-0-2" : null,
            "r158b58cde26-0-2" : "\"nam:nt:unstructured\""
    },
    ":childOrder" : {
            "r158b588cae9-0-2" : "\"[0]:Name\"",
            "r158b588d4ed-0-2" : null,
            "r158b58cde26-0-2" : "\"[0]:Name\""
    },
    "_deleted" : {
            "r158b588cae9-0-2" : "false",
            "r158b588d4ed-0-2" : "true",
            "r158b58cde26-0-2" : "false"
    },
    "_commitRoot" : {
            "r158b588cae9-0-2" : "4",
            "r158b588d4ed-0-2" : "4",
            "r158b58cde26-0-2" : "4"
    },
    "_modified" : NumberLong(1480514655),
    "_modCount" : NumberLong(3),
    "_deletedOnce" : true

}

{
    "_id" : "5:/content/mac/authujul281469689982632/notifications/node123",
    "_deleted" : {
            "r158b586fd5d-0-2" : "false",
            "r158b587c23e-0-2" : "true"
    },
    "_commitRoot" : {
            "r158b586fd5d-0-2" : "4",
            "r158b587c23e-0-2" : "4"
    },
    "jcr:primaryType" : {
            "r158b586fd5d-0-2" : "\"nam:nt:unstructured\"",
            "r158b587c23e-0-2" : null
    },
    ":childOrder" : {
            "r158b586fd5d-0-2" : "\"[0]:Name\"",
            "r158b587c23e-0-2" : null
    },
    "_modified" : NumberLong(1480514320),
    "_modCount" : NumberLong(2),
    "_deletedOnce" : true

}

我想要“_deleted”下的最后一个属性为false的所有记录。这意味着从上面的两条记录中,将返回第一条记录。如何编写同样的mongodb查询。

0 个答案:

没有答案