0
私は次のような構造で文書を含むモンゴデータベースと流星のアプリケーションを持っている:値が入れ子になっているMiniMongoからドキュメントを取得するには?
_id: "1234567890",
blocks: [{
type: "block",
block_id: "foobar",
items: [
{
type: "sub",
sub_id: "111",
items: [
{
type: "question",
question_id: "aaa"
},
{
type: "question",
question_id: "bbb"
}
]
},
{
type: "question",
question_id: "aaa"
}
]
}]
私は「aaa
」のquestion_id
ですべての質問を見つけることができるようにしたいです。これまでのところ私は、これらのクエリを試してみましたが、どんな結果を返すのに苦労しています:
questions = MyColl.find({
$or: [{
blocks: {
items: {
$elemMatch: {question_id: 'aaa'}
}
}
},{
blocks: {
items: {
type: "sub",
items: {
question_id: 'aaa'
}
}
}
}]
}).count();
任意のアイデア?