Skip to content
Back to skills

Mongodb Mean

ASecurity

MongoDB database architecture for MEAN stack apps. Use when designing collections, schemas, indexes, relationships, and data modeling with Mongoose ODM.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 26, 2026
databasesgodatabasebackend

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add endorphin-ai/claude-code-teams --skill mongodb-mean --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mongodb Mean?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mongodb Mean
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/endorphin-ai-mongodb-mean/badge)](https://www.skillsdirectory.com/skills/endorphin-ai-mongodb-mean)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mongodb-mean
description: "MongoDB database architecture for MEAN stack apps. Use when designing collections, schemas, indexes, relationships, and data modeling with Mongoose ODM."
---

# Mongodb Mean

## Purpose

Design MongoDB database architectures for MEAN stack applications. Produce Mongoose schema definitions, index strategies, relationship patterns, and data modeling decisions that backend developers implement directly.

## Key Patterns

### Schema Design Principles
- **Embed vs Reference:** Embed data accessed together (comments in a post). Reference data accessed independently (user profiles from posts). If embedded array can grow unbounded, reference instead.
- **Schema-first with Mongoose:** Always define explicit schemas. Use Mongoose schema types, validators, and virtuals.
- **Denormalize for reads:** Duplicate frequently-read fields (e.g., author.name in posts) to avoid joins.

### Standard Mongoose Patterns
- Always include `{ timestamps: true }` — adds createdAt, updatedAt
- Soft delete pattern: `{ isDeleted: Boolean, deletedAt: Date }`
- Pagination-ready: always index on createdAt
- Enum validation: `{ role: { type: String, enum: ['user', 'admin'], default: 'user' } }`
- Reference pattern: `{ author: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true } }`

### Index Strategy
- Every query field gets an index
- Compound indexes for multi-field queries: `{ userId: 1, createdAt: -1 }`
- Unique indexes for natural keys: `{ email: 1 }` with `unique: true`
- Text indexes for search: `{ title: 'text', body: 'text' }`

### Relationship Patterns
- **One-to-Few (<=20):** Embed directly (addresses in user)
- **One-to-Many (20-1000):** Array of references (posts by user)
- **One-to-Millions:** Parent reference in child (log entries referencing server)
- **Many-to-Many:** Array of references on both sides, or junction collection

## Conventions

- Collection names: lowercase plural (users, posts, comments)
- Field names: camelCase (firstName, createdAt, isActive)
- Always include timestamps: true in every schema
- Always define toJSON transform to remove __v and convert _id to id
- Define indexes in schema file, not in application code
- Use Mongoose middleware (pre/post hooks) for cross-cutting concerns
- Validate at schema level (required, min/max, enum, match)

## Knowledge Strategy

- **Patterns to capture:** Schema designs that worked well, index strategies for common queries, relationship patterns
- **Examples to collect:** Complete schema files for common entities (User, Post, Comment, Product, Order)
- **Update permission:** Agents may freely add/update files in `references/`. Changes to `SKILL.md` or `scripts/` require user approval.

Files in this skill

  • DRY_RUN.md2 KB
  • FORMAT.md3.1 KB
  • SKILL.md2.7 KB
  • VOICE.md1.8 KB
  • workflows/bugfix.md681 B
  • workflows/feature.md828 B
  • workflows/review.md634 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in databases →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.