Registry / database / monastery

monastery

JSON →
library4.0.1jsnpmunverified

Monastery is a simple and straightforward ODM for MongoDB, designed to be minimal and unopinionated. Current stable version is 4.0.1, with a stable release cadence focused on Node.js >=14. It leverages native MongoDB driver features and provides a clean schema-less interface. Key differentiators include its lightweight footprint, no dependencies on other Mongoose-like strict schemas, and built-in TypeScript support. Monastery is ideal for projects that need a thin data layer without the overhead of a full ORM.

npm install monastery
INSTALL
IMPORT
SIG · MONASTERY
M
monastery
databasejavascriptv4.0.1
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.

Monastery
import { Monastery } from 'monastery'
const Monastery = require('monastery')
ESM is required for v4; CommonJS require will fail.
Client
import { Client } from 'monastery'
Client is the main class to instantiate a MongoDB connection.
Model
import { Model } from 'monastery'
import Model from 'monastery'
Default export is not present; use named import for Model.

Shows connecting to MongoDB, creating and finding documents with Monastery ODM.

import { Monastery, Client, Model } from 'monastery'; async function main() { const client = new Client({ uri: process.env.MONGO_URI ?? 'mongodb://localhost:27017', dbName: 'test' }); await client.connect(); const monastery = new Monastery(client); const User = monastery.model('User'); const newUser = await User.create({ name: 'Alice', age: 30 }); console.log('Created:', newUser); const users = await User.find({ name: 'Alice' }); console.log('Found:', users); await client.close(); } main().catch(console.error);
Debug
Known issues
breakingVersion 4 drops CommonJS support; only ESM is supported.
fix
Use ES module imports and set 'type': 'module' in package.json.
affects: >=4.0.0
breakingThe 'Monastery' class constructor now requires a Client instance, not a direct URI string.
fix
Instantiate a Client first: new Client({ uri, dbName }) and then new Monastery(client).
affects: >=4.0.0
gotchaModel.find() returns documents directly, not a cursor; chaining .toArray() is not needed and throws an error.
fix
Use async/await to get the array directly from Model.find() without calling .toArray().
affects: >=4.0.0
deprecatedThe 'save()' method is deprecated; use 'create()' or 'insertOne()' instead.
fix
Replace save() with Model.create() for new documents or update queries.
affects: >=3.5.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Using CommonJS require() with an ES Module in version 4.
fix
Switch to import statement or downgrade to version 3.
TypeError: Monastery is not a constructor
Importing default instead of named import in ESM.
fix
Use import { Monastery } from 'monastery' instead of import Monastery from 'monastery'.
MongoError: Cannot find index '...' for filter
Using find() with unsupported query operators or missing indexes.
fix
Ensure indexes are created and use supported query operators as per MongoDB documentation.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
mongodbrequiredNative MongoDB driver is a peer dependency for database operations.
Agent activity
2 hits · last 30 days
node
2
Resources
monastery — npm install monastery · libregistry