cry-db is a TypeScript-first MongoDB wrapper library, currently stable at version 2.4.31. Its versioning suggests active development, though a specific release cadence isn't published. It offers a high-level, opinionated API for common database operations, abstracting away direct MongoDB driver interactions. Key differentiators include built-in support for document revisions, soft-delete functionality, archiving, blocking, and auditing, which simplify complex data lifecycle management. The library also provides real-time publish events, enabling reactive applications. It offers two main interfaces: `Mongo` for flexible multi-collection operations and `Repo<T>` for type-safe, single-collection convenience. Connection details are automatically managed via `MONGO_URL` and `MONGO_DB` environment variables, streamlining setup. A central feature is its unique record lifecycle, where soft-deleted and archived records are filtered from standard queries by default, requiring explicit options to retrieve them.
npm install cry-dbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic CRUD operations using both the `Repo` and `Mongo` classes, including an example of soft-delete and how to retrieve filtered records, and highlights the reliance on environment variables for MongoDB connection.
To retrieve soft-deleted records, pass `{ returnDeleted: true }` in `QueryOpts`. For archived records, use `{ returnArchived: true }`. To bypass all filters, use `findAll`.To permanently remove a document from the database, use `hardDeleteOne()` or `hardDelete()`.
Ensure `process.env.MONGO_URL` and `process.env.MONGO_DB` are correctly configured in your application environment or explicitly pass the database name to the `Repo` or `Mongo` constructor.
Be aware of these automatic field additions and updates, especially when performing partial updates or expecting specific document shapes. Integrate `_rev` and `_ts` into your document interfaces (`T`) for type safety if using `Repo<T>`.
Ensure your MongoDB instance is running. Verify that `process.env.MONGO_URL` (or the explicit database name in the constructor) is correctly pointing to your MongoDB server address and port.
When calling query methods like `find` or `findOne`, pass `{ returnDeleted: true }` and/or `{ returnArchived: true }` in the options object to include these records in the results. Alternatively, use `findAll` which bypasses these filters.No dependency data recorded yet.