MongoDB - 这个查询是否可以使用非规范化模型?

MongoDB - is this query possibile with denormalized model?

我有这个简单的 Mongodb 文档:

{
            "_id" : ObjectId("55663d9361cfa81a5c48d54f")
            "name" : "Oliver",
            "surname" : "Queen",
            "age" : 25,
            "friends" : [
                {
                        "name" : "Jhon",
                        "surname" : "Diggle",
                        "age" : "30"
                },
                {
                        "name" : "Barry",
                        "surname" : "Allen",
                        "age" : "24"
                }
        ]
}

是否可以使用上述非规范化模型找到 Oliver 所有 24 岁的朋友? 我认为标准化模型真的很简单;做两个查询就足够了。 例如以下查询:

db.collection.find({name:"Oliver", "friends.age":24}, {_id:0, friends:1})

returns 一组 Oliver 的朋友。是否可以选择 内部文档

使用aggregation

db.collection.aggregate(
    [
        { $match: { "name": "Oliver" }},
        { $unwind: "$friends" }, 
        { $match: { "friends.age": 24 }}, 
        { $group: { "_id": "$_id", friends: { "$push": "$friends" }}}, 
        { $project: { "_id": 0, "friends": 1 }}
    ]
)