Marpat is a lightweight ES6 class-based ODM (Object Document Mapper) for MongoDB and NeDB, forked from Camo. It provides a storage-agnostic document collection backend with schema validation via Joi since v3.0.0. Current stable version is 3.0.5, with a release cadence of several months. Supports hooks, embedded documents, counting, and custom database drivers. Key differentiators: ES6 class syntax, support for NeDB (file or in-memory) and MongoDB, integrated Joi validation, and a client registry for custom backends. Requires Node >=8.
npm install marpatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to an in-memory NeDB database, defining a model class extending Document, creating and saving a document, and finding it back.
Ensure your schema properties comply with Joi validation rules. See migration docs.
Remove any reliance on snyk being part of marpat's dependencies.
Use const { Document } = require('marpat'); instead of import.Assign the returned database to a variable or use it within the async scope.
Use const { Document } = require('marpat');Run npm install nedb --save
Ensure property values match the declared type (e.g., Number, String).