I have a schema that looks like this:
> db.test.findOne()
{
"_id" : "1:1419552000",
"l0" : [
{
"l1" : [
"1",
"2",
"3",
"4"
]
},
{
"l1" : [
"11",
"12",
"13",
"14"
]
},
{
"l1" : [
"21",
"22",
"23",
"24"
]
},
{
"l1" : [
"31",
"32",
"33",
"34"
]
},
{
"l1" : [
"41",
"42",
"43",
"44"
]
}
]
}
I wish to be able to fetch a range of elements from within any of the arrays at level 1 (l1). But the $slice operator doesn't to be able to do that. Is this not possible at all?
> db.test.findOne({}, {"l0" : {$slice: 1}})
{
"_id" : "1:1419552000",
"l0" : [
{
"l1" : [
"1",
"2",
"3",
"4"
]
}
]
}
> db.test.findOne({}, {"l0.0.l1" : {$slice: 2}})
{
"_id" : "1:1419552000",
"l0" : [
...
returns the entire object
...
}
Any pointers or help is welcome. Thanks!
db.test.findOne({}, {"l0.0.l1" : {$slice: 2}})it should be:{ "_id" : "1:1419552000", "l0" : [ "2", "1" ] }or similar