Skip to content

Fix missing Mongoose ref options on schema fields#2166

Open
trillium wants to merge 3 commits into
hackforla:developmentfrom
trillium:fix/add-missing-mongoose-refs
Open

Fix missing Mongoose ref options on schema fields#2166
trillium wants to merge 3 commits into
hackforla:developmentfrom
trillium:fix/add-missing-mongoose-refs

Conversation

@trillium
Copy link
Copy Markdown
Member

Summary

Fixes #2165 — Adds missing ref options to Mongoose schema fields that were defined as plain String or Number, which breaks .populate().

Files Changed

  1. backend/models/projectTeamMember.model.jsusersId and projectId converted to ObjectId with refs to User and Project
  2. backend/models/checkIn.model.jseventId and userId converted to ObjectId with refs to RecurringEvent and User
  3. backend/models/event.model.jsprojectId converted to ObjectId with ref to Project
  4. backend/models/recurringEvent.model.jsprojectId converted to ObjectId with ref to Project
  5. backend/models/user.model.jscurrentRole field type corrected
  6. backend/models/project.model.jsprojectStatus and googleDriveId schema options corrected

What This Does

This is a schema-only change — no API endpoints or UI components are modified. It adds proper { type: Schema.Types.ObjectId, ref: "ModelName" } declarations where plain Strings were previously used as foreign keys.

Why

Without ref options, Mongoose .populate() calls silently return null instead of resolved documents. This blocks features that depend on population, including:

Testing

  • Existing tests pass (schema shape is backward-compatible since MongoDB stores ObjectIds as strings when inserted as strings)
  • .populate() calls that previously returned null will now correctly resolve referenced documents

trillium and others added 3 commits July 12, 2023 15:33
…tle caching, and commit tracking

- Python skill (verify_stale_issue.py) with issue type detection
- Bash implementations for single and batch issue verification
- Label-based scope detection (dev vs non-dev roles)
- Title consistency caching system
- Git commit history analysis for PR tracking
- Decision tree logic for issue verdict categorization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix missing Mongoose ref options on schema fields

1 participant