mongo-cursor-pagination icon indicating copy to clipboard operation
mongo-cursor-pagination copied to clipboard

Document aggregation

Open antony opened this issue 5 years ago • 5 comments

It looks like the aggregate method isn't documented in readme.md. Not sure if this was intentional or not.

antony avatar Dec 10 '18 09:12 antony

how to use the aggregate method ? May i know if you are already using aggregation using mongoose

chaitu14341 avatar Dec 20 '18 08:12 chaitu14341

@chaitu14341 Yes I am using aggregate extensively. The docs are in the source code here https://github.com/mixmaxhq/mongo-cursor-pagination/blob/master/src/aggregate.js#L5

antony avatar Dec 20 '18 22:12 antony

how to use the aggregate method ? May i know if you are already using aggregation using mongoose

No, with mongoose plugin there is only find method. I'm trying to add aggregate() into mongoose plugin but still not working as expected.


Update: Actually it works, I've just confused because the aggregate() method of this plugin add the $sort based on _id right after the aggregated results, which make my $geoNear results completely shuffled. Otherwise it works.

sangdth avatar Jan 03 '20 15:01 sangdth

@sangdth, I am not seeing aggregate.js being required or used in the mongoose.plugin.js. How were you able to use aggregate rather than find() or search()?

nathanielrindlaub avatar May 19 '22 21:05 nathanielrindlaub

Hi @nathanielrindlaub, unfortunately I forgot the context, it's 2020 my friend. But a quick look into the source code, I think you can't use aggregate() if you want to use it as Mongoose's plugin. Mongo and Mongoose are different things.

They export separated things in the index.js file, so I believe the last time I had to give up on using this code.

sangdth avatar May 21 '22 07:05 sangdth