Skill profile for Database Architect — Mongoose schemas, indexes, backup and restore.
Japan SSW Platform (
mmdc-wst)
backend/src/models/| Technology | Version | Notes |
|---|---|---|
| MongoDB Atlas | Cloud | Cluster: japansswcluster0.lvia1ct.mongodb.net, DB: japansswdb |
| Mongoose | v9 |
ODM, USE_MONGOOSE=true |
| mongodb-memory-server | v8 | In-memory DB for Jest tests |
| Model | File | Purpose |
|---|---|---|
User | User.js | Auth users (local + Google OAuth) |
UserProfile | UserProfile.js | Extended user profile data |
Job | Job.js | Job listings |
AdminJob | adminJob.js | Admin-managed job postings |
Application | Application.js | Job applications |
Company | Company.js | Company profiles |
Content | Content.js | CMS-style page content |
timestamps: true on schemasselect: false on sensitive fields (passwords, tokens)MONGODB_URI env var only — never hardcodeCONTENT_COLLECTION=contents, ABOUT_COLLECTION=aboutnpm run seed # Basic seed data
npm run seed:full # Comprehensive seed (clears first)
npm run seed:full:verbose # Comprehensive seed with verbose output
npm run seed:clear # Clear all seed data
npm run seed:clean # Clean seed (safe script)
npm run seed:featured # Seed 9 featured companies + 41 SSW jobs (pages/companies/)
npm run fix-seed # Fix inconsistent seed data
MongoDB Atlas free tier (M0) does not include automated backups. Use the
custom scripts in backend/scripts/ for all manual backups.
backend/scripts/backup-db.jsPure Node.js (no mongodump required). Exports every collection to timestamped
JSON files inside backups/<ISO-timestamp>/ at the repo root.
# Full backup (all collections)
cd backend && npm run backup
# Selective backup
node backend/scripts/backup-db.js --collections users,companies,jobs
# Custom output directory
node backend/scripts/backup-db.js --out /path/to/my-backups
Output layout:
backups/
└── 2026-03-24T14-46-12/
├── manifest.json ← metadata: date, DB name, doc counts
├── users.json
├── companies.json
├── jobs.json
└── ... ← one .json per collection
backend/scripts/restore-db.js# Restore all collections (additive — won't overwrite existing docs)
cd backend && npm run restore -- --from ../backups/2026-03-24T14-46-12
# Full replace (drop each collection first)
npm run restore -- --from ../backups/2026-03-24T14-46-12 --drop
# Restore specific collections only
npm run restore -- --from ../backups/2026-03-24T14-46-12 --collections users,companies
| Event | Action |
|---|---|
| Before any seed operation | npm run backup |
| Before a co-developer merge | npm run backup |
| Weekly (manual) | npm run backup, store outside repo |
| After full reseed | npm run backup to capture fresh state |
backups/is gitignored. Store backup archives in a shared drive or S3 bucket for team access. Never commit backup JSON files — they may contain PII.
| Field | Description |
|---|---|
createdAt | ISO 8601 backup timestamp |
database | Atlas database name |
collections.<name>.count | Document count per collection |
collections.<name>.file | Relative JSON filename |