Registry / database / mongoskin

mongoskin

JSON →
library2.1.0jsnpmunverified

Mongoskin is a thin layer above the official MongoDB Node.js driver (node-mongodb-native) that provides a more convenient API, including deferred collection binding, helper methods for common operations, and automatic handling of open/close connections. Version 2.1.0 is the latest stable release, but the project is no longer actively maintained and has been effectively superseded by the native driver's modern features (e.g., connect(), collection() without callbacks). It depends on mongodb ^2.0 and supports Node >= 0.4.0. Key differentiators: simplified db/collection creation (no callback required), db.bind() for easy collection access, and promise-like patterns for core operations.

npm install mongoskin
INSTALL
IMPORT
SIG · MONGOSKIN
M
mongoskin
databasejavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mongoskin default
import mongo from 'mongoskin'
const mongo = require('mongoskin')
Default import is the main entry; CommonJS require also works but ESM is preferred for modern projects.
Db
import { Db } from 'mongoskin'
const Db = require('mongoskin').Db
Named export for Db class; also importable via default: mongo.Db.
Server
import { Server } from 'mongoskin'
const Server = require('mongoskin').Server
Named export for Server class.
MongoClient
import { MongoClient } from 'mongoskin'
const MongoClient = require('mongoskin').MongoClient
MongoClient is re-exported from mongodb driver.

Connect to a MongoDB instance, bind a collection, and fetch documents using the simplified mongoskin API.

const mongo = require('mongoskin'); const db = mongo.db('mongodb://localhost:27017/mydb', { native_parser: true }); db.bind('users'); db.users.find().toArray((err, docs) => { if (err) throw err; console.log(docs); db.close(); });
Debug
Known issues
deprecatedMongoskin is largely deprecated in favor of the native MongoDB driver's modern API (e.g., MongoClient.connect with callbacks/promises). No new features will be added.
fix
Migrate to the mongodb package directly: const { MongoClient } = require('mongodb');
affects: >=2.0.0
gotchaCallbacks are optional in many mongoskin methods (e.g., db.collection() returns a collection without a callback), but for operations like find().toArray(), a callback is still required for asynchronous results.
fix
Always provide a callback or use a promise wrapper for async operations.
affects: >=1.0.0
gotchaThe db.close() method must be called after operations to release resources; otherwise, the Node.js process may hang.
fix
Call db.close() in the callback or use a try/finally block.
affects: >=1.0.0
gotchadb.bind() modifies the db object by adding a property for the collection name. This can conflict with existing properties or methods on the db object.
fix
Avoid binding collections with names that shadow built-in db methods (e.g., 'admin', 'grid').
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: db.collection is not a function
Using mongoskin but calling methods that belong to the native mongodb driver without proper import or initialization.
fix
Ensure you are using mongoskin's db object (created via mongo.db()) and not a native Db instance.
MongoError: topology was destroyed
Calling db.close() prematurely while asynchronous operations are still pending.
fix
Move db.close() inside the callback of the last operation or use a promise chain.
Cannot find module 'mongoskin'
Missing npm installation or incorrect require path.
fix
Run: npm install mongoskin --save
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency - provides the actual MongoDB driver
Agent activity
2 hits · last 30 days
node
2
Resources
mongoskin — npm install mongoskin · libregistry