Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB通过指定嵌套值来查找对象_Mongodb_Meteor - Fatal编程技术网

MongoDB通过指定嵌套值来查找对象

MongoDB通过指定嵌套值来查找对象,mongodb,meteor,Mongodb,Meteor,这是我的客户收藏。如您所见,它有一个answers字段,每个键都有一个应答标志。如何让所有回答任何一个问题的客户都认为正确?试试: [ { customer: { field 1: {}, field 2: {}, answers: { "BUSI_EXP": { "answered": true, "updated": "date" }, "NEW_HOME": { "answered":

这是我的客户收藏。如您所见,它有一个answers字段,每个键都有一个应答标志。如何让所有回答任何一个问题的客户都认为正确?

试试:

[
{
    customer: {
        field 1: {},
        field 2: {},
        answers: {
            "BUSI_EXP": { "answered": true, "updated": "date" },
            "NEW_HOME": { "answered": true, "updated": "date" },
            "VEHICLE": { "answered": true, "updated": "date" }
        }
    }
},
{
    customer: {
        field 1: {},
        field 2: {},
        answers: {
            "BUSI_EXP": { "answered": false, "updated": "date" },
            "NEW_HOME": { "answered": false, "updated": "date" },
            "VEHICLE": { "answered": true, "updated": "date" }
        }
    }
}
]
尝试:


谢谢你的回答。我刚刚编辑了这个问题。我没有问我真正想要什么。难道没有一种方法可以迭代键吗?这是实际收集的一小部分。答案字段大约有80个键。不,您必须使用$or指定键。谢谢您的回答。我刚刚编辑了这个问题。我没有问我真正想要什么。难道没有一种方法可以迭代键吗?这是实际收集的一小部分。答案字段大约有80个键。不,您必须使用$or指定键。
    db.collectionname.find({ $or:[{"customer.answers.BUSI_EXP.answered": true},
{"customer.answers.NEW_HOME.answered": true},
{"customer.answers.VEHICLE.answered": true}});