mongo-object provides a programmatic API for interacting with MongoDB documents and modifiers, simplifying operations like building query objects, applying modifiers, and validating document structures. The current stable version is 3.0.4, with regular updates from Long Shot Labs. It ships TypeScript types and is ESM-only since v3, requiring Node.js >=20. Key differentiators include a lightweight footprint, explicit support for MongoDB modifiers, and a focus on type safety.
npm install mongo-objectNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a MongoObject, getting/setting values, applying a $inc modifier, and serializing to JSON.
Migrate to ESM (i.e., use import instead of require) and ensure Node.js >=20.
Upgrade Node.js to version 20 or later.
Use alternative approaches to pass options, or check documentation for newer API.
Clone the document before passing if you need to preserve the original unchanged.
Pass a deep clone (e.g., structuredClone(doc)) if you want to isolate modifications.
Use import syntax instead: import { MongoObject } from 'mongo-object' or set type: module in package.json.Use named import: import { MongoObject } from 'mongo-object'.Use optional chaining or check with hasKey before accessing: if (obj.hasKey('a.b.c')) { obj.getValue('a.b.c') }.Upgrade to Node.js >=20 or bundle with a tool like webpack/rollup that can handle ESM.
No dependency data recorded yet.