exframe DB

raw JSON →
4.0.6 verified Fri May 01 auth: no javascript

A wrapper around Mongoose for MongoDB connection management within the Harmony Framework. Exframe-db provides Mongoose connection initialization and graceful shutdown integration with exframe-service. Version 4.0.6 requires Node >=18.0.0 and peer dependencies exframe-health 1.x, exframe-logger 3.x, and exframe-service 1.x. It ships TypeScript types. The package is tightly coupled to the Harmony Framework ecosystem and is not intended for standalone use. Compared to mongoose directly, it adds logging and lifecycle hooks.

error Cannot find module 'exframe-db'
cause Package not installed or missing from node_modules.
fix
Run npm install exframe-db
error TypeError: db.init is not a function
cause Wrong import style; using named import instead of default.
fix
Use const db = require('exframe-db') then db.init(...)
error Error: Cannot find module 'exframe-logger'
cause Peer dependency exframe-logger not installed.
fix
Run npm install exframe-logger@3.x
breaking Peer dependencies must be installed manually; npm does not install them automatically in some versions.
fix Run npm install exframe-health@1.x exframe-logger@3.x exframe-service@1.x
gotcha init() requires both logger and dbUrl; missing logger will cause undefined errors.
fix Ensure logger is created via require('exframe-logger').create(...)
gotcha Package is CommonJS only; ESM imports may fail without proper handling.
fix Use require() or configure your bundler to handle CJS interop.
breaking Requires Node >=18.0.0; downgrading Node may cause syntax errors.
fix Update Node to version 18 or later.
npm install exframe-db
yarn add exframe-db
pnpm add exframe-db

Initializes MongoDB connection with exframe-db using environment variables for logger token and database URL.

const db = require('exframe-db');
const logger = require('exframe-logger').create(process.env.LOGSENE_TOKEN || 'token');
db.init({ logger, dbUrl: process.env.MONGO_URL || 'mongodb://localhost:27017/harmony' });
console.log('Database initialized');