dblibrary

raw JSON →
1.338.0 verified Sat Apr 25 auth: no javascript

Internal library providing Mongoose setup, database models, and connection management for Node.js applications. Current version 1.338.0, updated frequently. Provides pre-configured schemas and utilities for MongoDB interactions. Not published on npm (likely internal Bitbucket package). Lacks documentation beyond generic README. Alternatives: Mongoose directly, Typegoose.

error Cannot find module 'dblibrary'
cause Package not installed or registry not configured.
fix
Add 'dblibrary' to package.json from internal registry: npm install dblibrary@1.338.0 --registry=https://internal-registry.example.com
error ERR_REQUIRE_ESM: require() of ES Module
cause Using CommonJS require() on an ESM-only package.
fix
Change to ESM imports: import { connectDB } from 'dblibrary'
error TypeError: connectDB is not a function
cause Importing connectDB incorrectly (e.g., as default export).
fix
Use named import: import { connectDB } from 'dblibrary'
error MongooseError: The `uri` parameter to `openUri()` must be a string
cause connectDB called without arguments or with non-string.
fix
Call connectDB with a valid MongoDB connection string: connectDB('mongodb://...')
gotcha connectDB does not accept options object; only connection string.
fix Pass connection string as first argument. For options, set environment variables or call mongoose.connect directly.
deprecated Model.find() returns raw documents, not lean by default.
fix Call .lean() explicitly if you want plain JavaScript objects.
breaking Version 1.338.0 changed export names: 'User' was previously 'UserModel'.
fix Update imports: 'UserModel' → 'User'.
gotcha The package does not support ESM/CJS dual packaging; only ESM.
fix Use ESM imports (import syntax). Do not use require().
npm install dblibrary
yarn add dblibrary
pnpm add dblibrary

Connects to MongoDB and creates a user record using dblibrary models.

import { connectDB, User } from 'dblibrary';

async function main() {
  await connectDB('mongodb://localhost:27017/test');
  const user = await User.create({ name: 'Alice' });
  console.log(user);
}
main();