-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination on subdocuments #129
Comments
@Mdhaker - Have you possibly got a solution to this? Looking to do something similar |
you could use aggregation framework - $unwind the array of subdocuments and then use $sort and $limit. |
If I understand correctly, in case of using aggregation framework we lose all Mongoose features, like methods, virtuals, post/pre hooks etc, because returned result is raw object, not wrapped by Mongoose. Is it right? If yes, then using aggregation with Mongoose don't have any sense. |
I want to know how to paginate on subdocuments . |
This is my schema
const schema = new mongoose.Schema({ // User profile data saved here profile : { }, trainings:[training], // User training courses data saved here sessions:[session], slug: { type: String }, path: { type: String }, slugs: { type: [String] }, createdAt: { type: Date, default: Date.now }, updatedAt: { type: Date }, status: { type: String, enum: userStatus, default:"inactive" }, }
Is there away to paginate the array of subdocuments lik trainings and sessions ?
The text was updated successfully, but these errors were encountered: