These are chat archives for LearnBoost/mongoose

Jan 2015
Jan 28 2015 03:18
@vkarpov15 Yes, I don't clearly wrote, sorry +)
I write tests its API. When there are validation errors, mongoose says that there is no handler for error. It turned out that handler there is only one connection, but on the other there. Is there any information how to work with errors in 3.9?
Ismael Gorissen
Jan 28 2015 09:00

Hello everyone, I have this query

this.find().sort("-count title").skip(offset).limit(limit).exec(callback);

and I want to do a group by or a distinct on title property, how can I achieve this ?

Valeri Karpov
Jan 28 2015 15:21

Since you want to skip() and limit(), you need aggregation framework to do this. . Something like

this.aggregate().sort({ count: -1, title: 1 }).skip(offset).limit(limit).group({ _id: '$title' }).exec(callback);

Should work

keep in mind, order of stages matters in aggregation framework, so if you switch the order of sort, skip, limit, and group above you'll get different results