A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.
- ✨ Flexible Connections: Choose to use a specific connection or fall back to a default connection, with an automatic creation of a connection if none is provided
- ✨ Plugin Integration: Automatically integrates
mongoose-aggregate-paginate-v2
,mongoose-paginate-v2
, and a custom normalization plugin for enhanced JSON output - 🛠 Predefined Schemas: Provides a set of commonly used schema definitions such as boolean, decimal128, number, objectId, and string
- 🛠 Customizable: Allows for custom schemas and settings, including automatic rounding and fixed decimal places for
Decimal128
fields - 🔄 Enhanced JSON Output: Adds an
id
field, removes_id
and__v
fields, excludes private fields, and convertsDecimal128
fields to strings in JSON output - 🧩 Reference Schema Creation: Easily create schema definitions for ObjectId references with attributes like
private
,required
, andunique
- 🧩 String Schema Creation: Generate string schema definitions with attributes such as
private
,required
,short
,trim
, andunique
- 🧩 Decimal128 Field Conversion: Set up getters to convert
Decimal128
fields to strings for easier handling in documents - 🧩 Document Conversion: Convert documents or ObjectIds to documents using specified models, with optional field selection
- Mongoose version 8.x
- Node.js version 18 or higher
Add dependency (example using pnpm).
pnpm add @kikiutils/mongoose
You can also use yarn, npm, or bun to add the dependency.
That's it! You're ready to use this package in your project. Check out the usage instructions below ✨.
Please refer to the examples folder for usage instructions of this package.