MongoDB-从对象内的数组中查找数据

MongoDB-从对象内的数组中查找数据,mongodb,mongodb-query,spring-data-mongodb,Mongodb,Mongodb Query,Spring Data Mongodb,我的数据库格式如下 { "_id" : ObjectId("56fc92adcf908c9f296e5885"), "_class" : "com.abc.ppm.dto.AccessAttemptDTO", "url" : "/myProject/edit", "ipAddress" : "127.0.0.1", "param" : { "iecode" : [ "P1234" ], "id" : [ "5696578c6d34f83

我的数据库格式如下

{
"_id" : ObjectId("56fc92adcf908c9f296e5885"),
"_class" : "com.abc.ppm.dto.AccessAttemptDTO",
"url" : "/myProject/edit",
"ipAddress" : "127.0.0.1",
"param" : {
    "iecode" : [ 
        "P1234"
    ],
    "id" : [ 
        "5696578c6d34f835dc632fdd "
    ]
},
"accessTime" : "30-3-2016 10:59:57",
"email" : "abc@gmail.com",
"entity" : "admin",
"entityCode" : ""
},

{
"_id" : ObjectId("56fc92adcf908c9f296e5887"),
"_class" : "com.abc.ppm.dto.AccessAttemptDTO",
"url" : "/myProject/edit",
"ipAddress" : "127.0.0.1",
"param" : {
    "iecode" : [ 
        "P1122"
    ],
    "id" : [ 
        "5696578c6d34f835dc632fdd "
    ]
},
"accessTime" : "30-3-2016 10:59:57",
"email" : "abc@gmail.com",
"entity" : "admin",
"entityCode" : ""
}


现在我想找到所有的enries,其中iecode是'P1234'。我该怎么做?(注意:iecodes值以字符串数组格式存储。)

您可以编写如下查询:

db.collectionName.find({"param.iecode": "P1234"})