Registry / database / mongodb-light

mongodb-light

JSON →
library2.0.8jsnpmunverified

Thin MongoDB wrapper that provides a lightweight, promise-based interface for MongoDB operations with a simplified API. Stable version 2.0.8, last updated 2020 (unmaintained since). Key differentiator: minimal abstraction over the official MongoDB driver, focusing on core CRUD operations without bloat. Currently in maintenance mode; no active development. Requires Node >=7.0.0.

npm install mongodb-light
INSTALL
IMPORT
SIG · MONGODB-LIGHT
M
mongodb-light
databasejavascriptv2.0.8
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.

default
import mongo from 'mongodb-light'
const mongo = require('mongodb-light')
Package is ESM-only; CommonJS require is not supported.
connect
import { connect } from 'mongodb-light'
const connect = require('mongodb-light').connect
Named export; available from package root.
MongoClient
import { MongoClient } from 'mongodb-light'
import MongoClient from 'mongodb-light'
MongoClient is a named export, not default.

Demonstrates basic connect, insert, and find operations using mongodb-light.

import { connect } from 'mongodb-light'; const uri = process.env.MONGO_URI ?? 'mongodb://localhost:27017'; const dbName = 'myapp'; async function main() { const client = await connect(uri); const db = client.db(dbName); const collection = db.collection('users'); // Insert a document const insertResult = await collection.insertOne({ name: 'Alice', age: 30 }); console.log('Inserted:', insertResult.insertedId); // Find documents const users = await collection.find({ name: 'Alice' }).toArray(); console.log('Found:', users); // Close connection await client.close(); } main().catch(console.error);
Debug
Known issues
deprecatedPackage is no longer actively maintained; last update 2020.
fix
Consider migrating to the official mongodb package or other maintained wrappers.
affects: >=2.0.0
gotchaRequires mongodb as a peer dependency; not automatically installed.
fix
Run 'npm install mongodb' alongside mongodb-light.
affects: >=2.0.0
breakingPackage is ESM-only; cannot be used with CommonJS require.
fix
Use ES import syntax or switch to a CJS-compatible library.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mongodb'
Missing peer dependency 'mongodb'.
fix
Install it: npm install mongodb
TypeError: mongo.connect is not a function
Using default import incorrectly; expected named import 'connect'.
fix
Use import { connect } from 'mongodb-light' instead of import mongo from ...
require() of ES Module not supported
Package is ESM-only; using CommonJS require.
fix
Convert to ES imports or use dynamic import() if needed.
Upgrade
Version history
2.0.8latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency; uses official MongoDB driver under the hood.
Agent activity
4 hits · last 30 days
node
4
Resources
mongodb-light — npm install mongodb-light · libregistry