Skip to content

fix: use HydratedDocument to resolve Document type conflict#8

Open
Daksh-Mehra wants to merge 1 commit intoadrianhajdin:mainfrom
Daksh-Mehra:fix/use-hydrated-document
Open

fix: use HydratedDocument to resolve Document type conflict#8
Daksh-Mehra wants to merge 1 commit intoadrianhajdin:mainfrom
Daksh-Mehra:fix/use-hydrated-document

Conversation

@Daksh-Mehra
Copy link
Copy Markdown

@Daksh-Mehra Daksh-Mehra commented Feb 14, 2026

Replaced extends Document with HydratedDocument to fix TypeScript property conflicts (e.g., 'location') and align with modern Mongoose typing.

Summary by CodeRabbit

  • Refactor
    • Updated internal type definitions across database models to improve code quality and type safety standards.

Replaced extends Document with HydratedDocument<T> to fix TypeScript property conflicts (e.g., 'location') and align with modern Mongoose typing.
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 14, 2026

@Daksh-Mehra is attempting to deploy a commit to the JS Mastery Pro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

Unified typing update across 9 database model files replacing interface-based document types with HydratedDocument type aliases. Each file adds HydratedDocument to mongoose imports and converts its document type declaration from an interface extending Document to a type alias.

Changes

Cohort / File(s) Summary
Database Model Type Migrations
database/account.model.ts, database/answer.model.ts, database/collection.model.ts, database/interaction.model.ts, database/question.model.ts, database/tag-question.model.ts, database/tag.model.ts, database/user.model.ts, database/vote.model.ts
Added HydratedDocument to mongoose imports; replaced document type declarations from export interface I{Entity}Doc extends I{Entity}, Document {} to export type I{Entity}Doc = HydratedDocument<I{Entity}> pattern across all model files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops through the schemas with delight,
HydratedDocument shines so bright,
From interfaces old, we now take flight,
Type aliases bloom, oh what a sight!
Nine models updated, everything's right!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: replacing Document interface extensions with HydratedDocument type aliases across database models to resolve TypeScript conflicts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
database/tag-question.model.ts (1)

1-1: Unused Document import.

Document is no longer referenced after switching to HydratedDocument. This applies to most files in this PR — only vote.model.ts correctly omits it.

Suggested fix
-import { model, models, Schema, Types, Document, HydratedDocument } from "mongoose";
+import { model, models, Schema, Types, HydratedDocument } from "mongoose";
database/tag.model.ts (1)

1-1: Unused Document import — same as noted in tag-question.model.ts.

database/collection.model.ts (1)

1-1: Unused Document import — same pattern as other files.

database/account.model.ts (1)

1-1: Unused Document import — same pattern as other files.

database/answer.model.ts (1)

1-1: Unused Document import — same pattern as other files.

database/user.model.ts (1)

1-1: Unused Document import — same pattern. Also, this is the key file where the location property conflict from the PR description would manifest, since IUser declares location?: string which conflicts with Document's inherited properties.

database/interaction.model.ts (1)

1-1: Unused Document import — same pattern as other files.

database/question.model.ts (1)

1-1: Remove the unused Document import.

Document is no longer referenced after switching to HydratedDocument<IQuestion>. Also, there's inconsistent spacing around Document.

🧹 Proposed fix
-import { model, models, Schema, Types, Document , HydratedDocument} from "mongoose";
+import { model, models, Schema, Types, HydratedDocument } from "mongoose";

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant