api-database-mongoose
SolidMongoDB ODM with schemas, validation, middleware, and TypeScript support
API & Backend 18 stars
6 forks Updated 1 weeks ago MIT
Install
Quality Score: 78/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Mongoose ODM Patterns
> **Quick Guide:** Use Mongoose as the ODM layer for MongoDB. Let TypeScript infer types from schema definitions instead of duplicating interfaces. Register all middleware before calling `model()` -- hooks added after compilation are silently ignored. Use `.lean()` for any read-only query. Pass `{ session }` to every operation inside a transaction or enable `transactionAsyncLocalStorage`. Prefer `session.withTransaction()` over manual commit/abort. Use `127.0.0.1` instead of `localhost` in connection strings (Node.js 18+ IPv6 preference causes timeouts).
---
<critical_requirements>
## CRITICAL: Before Using This Skill
> **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants)
**(You MUST define all middleware (pre/post hooks) BEFORE calling `model()` -- hooks registered after model compilation are silently ignored with no error)**
**(You MUST pass `{ session }` to EVERY operation inside a transaction -- missing session causes that operation to run outside the transaction silently)**
**(You MUST use `.lean()` for read-only queries returning API responses -- skipping lean wastes 3x memory on hydration overhead)**
**(You MUST use `127.0.0.1` instead of `localhost` in connection strings -- Node.js 18+ prefers IPv6 and `localhost` causes connection timeouts)**
**(You MUST NOT use `findOneAndUpdate`/`updateOne` and expect `pre('save')` to fire -- only `save()` and `create...
Details
- Author
- agents-inc
- Repository
- agents-inc/skills
- Created
- 8 months ago
- Last Updated
- 1 weeks ago
- Language
- N/A
- License
- MIT
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
API & Backend Solid
api-database-mongodb
MongoDB with Mongoose ODM - schemas, models, queries, aggregation, indexes, TypeScript typing, connection management
18 Updated 1 weeks ago
agents-inc API & Backend Listed
mongodb
Work with MongoDB databases using best practices. Use when designing schemas, writing queries, building aggregation pipelines, or optimizing performance. Triggers on MongoDB, Mongoose, NoSQL, aggregation pipeline, document database, MongoDB Atlas.
2 Updated yesterday
Makiya1202 API & Backend Solid
api-database-typeorm
Decorator-based ORM for TypeScript with Active Record and Data Mapper patterns
18 Updated 1 weeks ago
agents-inc