我有 mongo DB 集合,即具有以下文档结构的学生,
名称:详细信息:日期:值
因此,对于单个名称,我们将有一个详细信息列表,
该详细信息列表将包含多个日期列表
每个日期列表将有多个值列表
{
"_id" : ObjectId("51472e9fd29a736d83c27ca3"),
"name" : "Arun",
"details" : [
{
"date" : "2015-01-17",
"isNew" : false,
"isOld" : true,
"values" : [
{
"money" : "330.0",
"new" : false,
"old" : true,
},
{
"money" : "340.0",
"new" : false,
"old" : true,
}
]
},
{
"date" : "2015-01-17",
"isNew" : false,
"isOld" : false,
"values" : [
{
"money" : "330.0",
"new" : false,
"old" : false,
},
{
"money" : "340.0",
"new" : false,
"old" : false,
}
]
},
{
"date" : "2015-01-17",
"isNew" : true,
"isOld" : false,
"values" : [
{
"money" : "330.0",
"new" : true,
"old" : false,
},
{
"money" : "340.0",
"new" : true,
"old" : false,
}
]
},
{
"date" : "2013-10-19",
"isNew" : true,
"isOld" : false,
"values" : [
{
"money" : "330.0",
"new" : true,
"old" : false,
},
{
"money" : "340.0",
"new" : true,
"old" : false,
}
]
}
]
}
What is need is, i want to SELECT "all the date lists" where "name" : "Arun" and "date" : "2015-01-17",I tried this way and it is not working as expected.I am getting all the dates instead 2015-01-17 in return.
I think only one where condition is working here and that is "name" : "Arun" , Query is not considering "details.date" : "2015-01-17" in where condition.
db.student.find({ "details.date" : "2015-01-17","name" : "Arun" },{"details.date":1}).pretty()
{
"_id" : ObjectId("51472e9fd29a736d83c27ca3"),
"details" : [
{
"date" : "2015-01-17"
},
{
"date" : "2015-01-17"
},
{
"date" : "2015-01-17"
},
{
"date" : "2013-10-19"
}
]
}
我目前正在使用 mongo 1.6.5
有人可以帮我解决这个问题吗?