Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-paginate-v2

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-paginate-v2

A cursor based custom pagination library for Mongoose with customizable labels.

  • 1.3.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
137K
increased by5.38%
Maintainers
1
Weekly downloads
 
Created

What is mongoose-paginate-v2?

mongoose-paginate-v2 is a pagination library for Mongoose, which is a MongoDB object modeling tool designed to work in an asynchronous environment. This package simplifies the process of adding pagination to Mongoose queries, making it easier to handle large datasets by breaking them into manageable chunks.

What are mongoose-paginate-v2's main functionalities?

Basic Pagination

This feature allows you to paginate through documents in a Mongoose model. The example demonstrates how to set up a schema with the pagination plugin and perform a basic pagination query.

const mongoose = require('mongoose');
const mongoosePaginate = require('mongoose-paginate-v2');

const schema = new mongoose.Schema({ name: String });
schema.plugin(mongoosePaginate);
const Model = mongoose.model('Model', schema);

Model.paginate({}, { page: 1, limit: 10 }).then(result => {
  console.log(result);
});

Custom Pagination Options

This feature provides various options to customize the pagination query, such as sorting, selecting specific fields, and populating related documents. The example shows how to use these options in a pagination query.

const options = {
  page: 1,
  limit: 10,
  sort: { name: 1 },
  select: 'name',
  populate: 'relatedModel'
};

Model.paginate({}, options).then(result => {
  console.log(result);
});

Aggregation Pagination

This feature allows you to paginate the results of an aggregation query. The example demonstrates how to use the `aggregatePaginate` method to paginate through aggregation results.

const aggregate = Model.aggregate([{ $match: { name: 'example' } }]);

Model.aggregatePaginate(aggregate, { page: 1, limit: 10 }).then(result => {
  console.log(result);
});

Other packages similar to mongoose-paginate-v2

Keywords

FAQs

Package last updated on 01 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc