私はmongo DBコレクション、つまり次のドキュメント構造を持つ学生を持っています。
名前:詳細:日付:値
したがって、名前が 1 つの場合、詳細リストは 1 つになります。
その詳細リストには複数の日付リストがあります
そして、各日付リストには複数の値リストがあります
{
"_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を使用しています
誰かがこれを解決するのを手伝ってくれますか?