{"id":44046,"library":"to-mongodb-core","title":"to-mongodb-core","description":"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.","status":"abandoned","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sorribas/to-mongodb-core","tags":["javascript"],"install":[{"cmd":"npm install to-mongodb-core","lang":"bash","label":"npm"},{"cmd":"yarn add to-mongodb-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add to-mongodb-core","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package has CJS default export; ESM import requires default import.","wrong":"const toMongodbCore = require('to-mongodb-core').default","symbol":"default","correct":"import toMongodbCore from 'to-mongodb-core'"},{"note":"CommonJS usage: entire module is a single function.","wrong":"const { toMongodbCore } = require('to-mongodb-core')","symbol":"require","correct":"const toMongodbCore = require('to-mongodb-core')"},{"note":"Package has no TypeScript declarations; use custom type or @ts-ignore.","wrong":"import toMongodbCore from 'to-mongodb-core'; // no type definitions","symbol":"TypeScript types","correct":"// @ts-ignore\ntype ToMongodbCore = (db: any, cb: (err: Error | null, core: any) => void) => void;\nconst toMongodbCore: ToMongodbCore = require('to-mongodb-core');"}],"quickstart":{"code":"const mongojs = require('mongojs');\nconst toMongodbCore = require('to-mongodb-core');\n\nconst db = mongojs('mongodb://localhost:27017/mydb');\n\ntoMongodbCore(db, (err, mdbcore) => {\n  if (err) {\n    console.error(err);\n    return;\n  }\n  console.log('Got mongodb-core instance:', mdbcore);\n  // Use mdbcore for low-level operations\n});","lang":"javascript","description":"Shows how to extract mongodb-core instance from a mongojs database connection using the default export."},"warnings":[{"fix":"Use the official mongodb driver directly instead of mongojs and to-mongodb-core.","message":"Package is no longer maintained and has no recent updates.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure you pass a mongojs database object, not a mongodb.Db instance.","message":"Function expects a mongojs instance, not a mongodb driver instance directly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check the type of mdbcore and handle both cases.","message":"Callback may receive a mongodb-core Server or ReplSet instance depending on connection type.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.0':20 'advanc':46 'api':37 'base':36 'callback':35 'callback-bas':34 'core':4,10,42 'direct':62 'driver':17,43,61 'expos':50 'extract':5 'instanc':11,18 'instead':63 'javascript':64 'longer':28 'maintain':29 'mongodb':3,9,16,47,60 'mongodb-cor':8 'mongoj':14,52 'new':56 'obtain':39 'oper':48 'packag':25 'project':57 'provid':31 'raw':41 'recommend':54 'simpl':33 'stabl':22 'to-mongodb-cor':1 'under':7 'use':44,58 'version':19","created_at":"2026-06-05T17:02:42.811508+00:00","updated_at":"2026-06-05T17:02:42.811508+00:00","problems":[{"fix":"Run: npm install to-mongodb-core","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'to-mongodb-core'"},{"fix":"Use: const toMongodbCore = require('to-mongodb-core');","cause":"Using destructured import (common mistake with default exports).","error":"TypeError: toMongodbCore is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sorribas/to-mongodb-core","github":"https://github.com/sorribas/to-mongodb-core","docs":null,"changelog":null,"pypi":null,"npm":"to-mongodb-core","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}