Registry / database / objy-mapper-mongodb

objy-mapper-mongodb

JSON →
library0.0.14jsnpmunverified

A storage mapper for MongoDB that integrates with the OBJY object-relational mapping framework. Current version 0.0.14 is in early development with infrequent releases. It simplifies MongoDB persistence for OBJY-defined object families by providing a connect-and-use interface. Key differentiators: tightly coupled with OBJY for a unified object mapping experience; minimal configuration; suitable for small projects or prototypes. Note that the package has limited documentation and may not be production-ready.

npm install objy-mapper-mongodb
INSTALL
IMPORT
SIG · OBJY-MAPPER-MONGOD
O
objy-mapper-mongodb
databasejavascriptv0.0.14
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.

MongoMapper
const MongoMapper = require('objy-mapper-mongodb');
import MongoMapper from 'objy-mapper-mongodb';
The package does not support ESM imports; only CommonJS require is available.
MongoMapper.connect
const mapper = new MongoMapper().connect('mongodb://localhost');
const mapper = MongoMapper.connect('mongodb://localhost');
connect must be called on an instance of MongoMapper, not the class itself.
OBJY.define
const OBJY = require('objy'); OBJY.define({...});
const { define } = require('objy'); define({...});
OBJY is a singleton; direct named import of define is not supported.

Shows how to define an OBJY object family with MongoDB storage using the mapper, then create and save an object.

const MongoMapper = require('objy-mapper-mongodb'); const OBJY = require('objy'); // Define an object family with MongoDB storage OBJY.define({ name: 'Test', pluralName: 'Tests', storage: new MongoMapper().connect('mongodb://localhost:27017/mydb') }); // Create and persist an object OBJY.Test({ message: 'Hello World' }).add((data) => { console.log('Saved:', data); });
Debug
Known issues
gotchaPackage name typo in README: 'require('objy-mapper-monodb')' missing 'g' in 'mongodb'.
fix
Use correct import: require('objy-mapper-mongodb')
affects: <=0.0.14
breakingMissing dependency: 'objy' must be installed separately; not listed as peer dependency.
fix
npm install objy alongside this package.
affects: >=0.0.1
deprecatedOld MongoDB driver may be used; version not specified.
fix
Check mongodb driver compatibility; may need to update.
affects: >=0.0.0
gotchaESM imports not supported; only CommonJS require works.
fix
Use require() instead of import statements.
affects: >=0.0.0
gotchaOBJY.define must be called before using the object family constructor.
fix
Always define the family before creating instances.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'objy-mapper-monodb'
Typo in package name: missing 'g' in 'mongodb'.
fix
Correct the require path to 'objy-mapper-mongodb'.
TypeError: MongoMapper is not a constructor
Importing the class incorrectly (e.g., using ESM import that returns undefined).
fix
Use require('objy-mapper-mongodb') to get the constructor.
OBJY is not defined
OBJY package not installed or imported.
fix
npm install objy and require('objy') before usage.
Upgrade
Version history
0.0.14latest on npm
Audit
Dependencies
mongodbrequiredRequired to interact with MongoDB database.
objyrequiredRequired to define object families and use the mapper.
Agent activity
2 hits · last 30 days
node
2
Resources
objy-mapper-mongodb — npm install objy-mapper-mongodb · libregistry