Info
db.getCollection('SomeCollection').find({}, {'array.0':1})
I would expect the above to return documents like:
{array:[{a:'a',b:'b'}]}
but instead returns all elements of the array, just as empty objects:
{array:[{}, {}, {}]}
This doesn't make any sense. It seem broken.
Top User Comments
thomas.schubert commented on Tue, 11 Jul 2017 22:24:27 +0000:
Hi fresheneesz,
Please note that this behavior is documented. I would recommend using the $slice to achieve the functionality you're looking for:
db.getCollection('SomeCollection').find({}, {array:{$slice:1}})
Kind regards,
Thomas
fresheneesz commented on Tue, 11 Jul 2017 21:34:54 +0000:
Thanks Thomas!
fresheneesz commented on Tue, 11 Jul 2017 21:04:58 +0000:
Ugh, freaking jira "preformatted" style didn't work.. why can't I edit the ticket I created? Well... ignore the first two and last two curly braces then...