Registry / database / to-mongodb-core

to-mongodb-core

JSON →
library2.0.0jsnpmunverified

Extracts the underlying mongodb-core instance from a mongojs or mongodb driver instance. Version 2.0.0 is stable but the package is no longer maintained. It provides a simple callback-based API to obtain the raw core driver, useful for advanced MongoDB operations not exposed by mongojs. Not recommended for new projects; use the mongodb driver directly instead.

npm install to-mongodb-core
INSTALL
IMPORT
SIG · TO-MONGODB-CORE
T
to-mongodb-core
databasejavascriptv2.0.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.

default
import toMongodbCore from 'to-mongodb-core'
const toMongodbCore = require('to-mongodb-core').default
Package has CJS default export; ESM import requires default import.
require
const toMongodbCore = require('to-mongodb-core')
const { toMongodbCore } = require('to-mongodb-core')
CommonJS usage: entire module is a single function.
TypeScript types
// @ts-ignore type ToMongodbCore = (db: any, cb: (err: Error | null, core: any) => void) => void; const toMongodbCore: ToMongodbCore = require('to-mongodb-core');
import toMongodbCore from 'to-mongodb-core'; // no type definitions
Package has no TypeScript declarations; use custom type or @ts-ignore.

Shows how to extract mongodb-core instance from a mongojs database connection using the default export.

const mongojs = require('mongojs'); const toMongodbCore = require('to-mongodb-core'); const db = mongojs('mongodb://localhost:27017/mydb'); toMongodbCore(db, (err, mdbcore) => { if (err) { console.error(err); return; } console.log('Got mongodb-core instance:', mdbcore); // Use mdbcore for low-level operations });
Debug
Known issues
deprecatedPackage is no longer maintained and has no recent updates.
fix
Use the official mongodb driver directly instead of mongojs and to-mongodb-core.
affects: >=2.0.0
gotchaFunction expects a mongojs instance, not a mongodb driver instance directly.
fix
Ensure you pass a mongojs database object, not a mongodb.Db instance.
affects: >=1.0.0
gotchaCallback may receive a mongodb-core Server or ReplSet instance depending on connection type.
fix
Check the type of mdbcore and handle both cases.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'to-mongodb-core'
Package not installed or not in node_modules.
fix
Run: npm install to-mongodb-core
TypeError: toMongodbCore is not a function
Using destructured import (common mistake with default exports).
fix
Use: const toMongodbCore = require('to-mongodb-core');
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
8
Meta
2
Amazon
1
OpenAI (training)
1
Resources
to-mongodb-core — npm install to-mongodb-core · libregistry