vg-mongo is a lightweight MongoDB client wrapper built on top of the official mongodb package, providing a simplified interface for common database operations with built-in pagination support. The current stable version is 2.0.0. It simplifies collection access and adds a paginate method for querying documents with limit, page, and sort options. Key differentiator: eliminates boilerplate for MongoDB pagination compared to using the raw mongodb driver.
npm install vg-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to MongoDB, accesses a collection, inserts a doc, and uses paginate to retrieve results.
Change require('vg-mongo') to import vgMongo from 'vg-mongo' in Node 14+ with type: module or .mjs extension.Replace skip option with page and limit. Page starts at 1, not 0.
Use db.myCollection directly (dynamic property) instead of db.collection('myCollection').Use paginatedResults.docs and paginatedResults.total. Calculate totalPages = Math.ceil(total / limit).
Remove deprecated options from connection string or second argument. For modern mongodb driver, these options are ignored.
Run `npm install vg-mongo` in your project root.
Ensure first argument is a valid MongoDB connection string, e.g., 'mongodb://localhost:27017'.
Use direct property access: const myCollection = db.myCollection;
Set page to >=1 (e.g., page: 1). Pages are 1-indexed.
Set limit to >=1 (e.g., limit: 10).