aravindnc / mongoose-aggregate-paginate-v2

A cursor based custom aggregate pagination library for Mongoose with customizable labels.
MIT License
131 stars 23 forks source link

Can groups be paginated separately? #34

Closed i-rebel-aj closed 3 years ago

i-rebel-aj commented 3 years ago

I have aggregated my collection such that, I am generating documents with _id being the grouping condition and I am pushing all the documents that fall into this group in an array. So my final output is like:

{_id: 'Student Class1', studentsInThisClass:[ ... ]},
{_id: 'Student Class2', studentsInThisClass:[ ... ]},
...

Can I paginate solely on the basis of groups.. my expected output Groups themselves might be paginated too

   {_id:'Student Class 1', docs:[ .... ]} ,
   {_id:'Student Class 2', docs:[ .... ]} ,

Is it currently supported?

If my final step in aggregation pipeline is

'$group': {
      '_id': '$student.class', 
      'classInfo': {
        '$push': '$$ROOT'
      }
    }
aravindnc commented 3 years ago

@i-rebel-aj Sorry that is not supported.