I have a collection of users and in each document there is an array of objects.
I want to group all these objects together BUT only want to return 5 results at a time. I tried to use {$limit: 5}
but it doesn't seem to return just 5 objects.
This is my code:
var res = Meteor.users.aggregate([
{$unwind : "$docUploaded"},
{$group:{_id: null, val:{$push:'$docUploaded'}}},
{$limit:5}] );
console.log(res);
How can I just limit it to 5 objects rather than all objects that are currently returned?