Registry / database / subito-connector-mongodb

subito-connector-mongodb

JSON →
library0.12.2jsnpmunverified

Subito MongoDB connector is a TypeScript library, currently at v0.12.2, providing a wrapper around the official MongoDB Node.js driver with a focus on subito microservices architecture. It offers a simplified interface for database operations, connection management, and transaction support. The package is released on npm and is designed for server-side (Node.js) environments. It differs from raw mongodb usage by abstracting connection handling, providing built-in health checks, and integrating with the Subito ecosystem. Active development with monthly releases.

npm install subito-connector-mongodb
INSTALL
IMPORT
SIG · SUBITO-CONNECTOR-M
S
subito-connector-mongodb
databasejavascriptv0.12.2
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.

MongoClient
import { MongoClient } from 'subito-connector-mongodb'
const MongoClient = require('subito-connector-mongodb').MongoClient
This package is ESM-only; use named import for MongoClient.
default
import SubitoMongo from 'subito-connector-mongodb'
import { SubitoMongo } from 'subito-connector-mongodb'
Default export is the main class; named export is not available for default.
MongoConnection
import type { MongoConnection } from 'subito-connector-mongodb'
import { MongoConnection } from 'subito-connector-mongodb'
MongoConnection is a type; use 'import type' to avoid runtime errors.

Shows connecting to MongoDB, inserting a document, and closing connection using SubitoMongo class.

import SubitoMongo from 'subito-connector-mongodb'; const config = { uri: process.env.MONGO_URI ?? 'mongodb://localhost:27017', dbName: 'myapp', }; async function start() { const db = new SubitoMongo(config); await db.connect(); const collection = db.collection('users'); const result = await collection.insertOne({ name: 'Alice' }); console.log('Inserted:', result.insertedId); await db.close(); } start().catch(console.error);
Debug
Known issues
breakingIn version 0.10.0, the default export changed from a function to a class. Upgrade requires using 'new SubitoMongo(config)' instead of direct call.
fix
Replace 'SubitoMongo(config)' with 'new SubitoMongo(config)'.
affects: <0.10.0
deprecatedMethod 'close()' is deprecated since 0.12.0; use 'disconnect()' instead.
fix
Replace db.close() with db.disconnect().
affects: >=0.12.0
gotchaThe package uses ES Modules (ESM). Using require() will fail with 'ERR_REQUIRE_ESM'.
fix
Use import statements or dynamic import() in CommonJS modules.
affects: >=0.9.0
breakingAs of version 0.11.0, the minimum Node.js version is 14.0.0.
fix
Update Node.js to v14 or later.
affects: >=0.11.0
Errors
Common errors & fixes
TypeError: SubitoMongo is not a constructor
Using default import without 'new' on old version (<0.10.0) or using require() on ESM version.
fix
For >=0.10.0, use 'new SubitoMongo(config)'. Ensure you are using import or dynamic import.
ERR_REQUIRE_ESM
Attempting to use require() to load this ESM-only package.
fix
Use import statement or use dynamic import: const SubitoMongo = await import('subito-connector-mongodb')
MongoError: Authentication failed
Incorrect credentials in URI or missing 'authSource' option.
fix
Ensure URI includes username/password and optionally set authSource: 'admin' in config.
Upgrade
Version history
0.12.2latest on npm
Audit
Dependencies
mongodbrequiredCore MongoDB driver for database interaction
Agent activity
18 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
subito-connector-mongodb — npm install subito-connector-mongodb · libregistry