Skip to content

A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.

License

Notifications You must be signed in to change notification settings

kiki-kanri/kikiutils-node-mongoose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

58d10b3 Â· Feb 19, 2025
Nov 18, 2024
Nov 18, 2024
Jan 5, 2025
Feb 19, 2025
Dec 15, 2024
Jul 19, 2024
Feb 19, 2025
Apr 16, 2024
Oct 28, 2024
Nov 18, 2024
Dec 13, 2024
Feb 19, 2025
Feb 19, 2025
Oct 23, 2024
Jan 5, 2025

Repository files navigation

@kikiutils/mongoose

npm version npm downloads codecov License

A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.

Features

  • ✨ Flexible Connections: Supports both default and custom connections, automatically creating connections when none are provided
  • 🔌 Plugin Integration: Automatically integrates mongoose-aggregate-paginate-v2, mongoose-paginate-v2, and custom normalization for cleaner JSON outputs
  • 🛠 Predefined & Customizable Schemas: Provides common schemas (boolean, date, decimal128, number, objectId, string) with the flexibility to customize attributes such as private, required, unique, default, and more
  • 🧮 Decimal Precision: Supports Decimal128 fields with options for automatic rounding and fixed decimal precision
  • 🔄 Optimized JSON Output: Adds an id field, removes _id and __v, hides private fields, and converts Decimal128 fields to strings in JSON responses
  • 🔄 Reference Management: Enables easy conversion of ObjectId references to fully populated documents with field selection and population options
  • 🔧 Utility Functions: Includes helper functions for converting and normalizing documents, handling ObjectId transformations, and processing schema fields

Environment Requirements

  • Mongoose version 8.x
  • Node.js version 18.12.1 or higher

Installation

Add dependency (example using pnpm).

pnpm add @kikiutils/mongoose 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 ✨.

Usage

Please refer to the examples folder for usage instructions of this package.

License

MIT License

About

A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.

Resources

License

Stars

Watchers

Forks