-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add upsert repo #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changelog file documenting the project's release history was deleted. In the codebase, the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BaseRepository
participant MongooseModel
Caller->>BaseRepository: upsert(filter, update, options)
BaseRepository->>MongooseModel: updateOne(filter, update, { upsert: true, ...options })
MongooseModel-->>BaseRepository: Promise (result)
BaseRepository-->>Caller: Promise (result)
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn config production Use ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/repositories/base.repository.ts (1)
2-9
: Consider the implications of removing type-only imports.The change from
import type { ... }
toimport { ... }
could impact bundle size and compilation. Since these are all TypeScript types from mongoose, usingimport type
is generally preferred unless these imports are needed at runtime.If these types are only used for type annotations, consider reverting to type-only imports:
import { - FilterQuery, - HydratedDocument, - LeanDocument, - Model, - PopulateOptions, - ProjectionType, - QueryOptions, - UpdateQuery, + type FilterQuery, + type HydratedDocument, + type LeanDocument, + type Model, + type PopulateOptions, + type ProjectionType, + type QueryOptions, + type UpdateQuery, } from 'mongoose';However, if this change was made to resolve TypeScript compilation issues, the current approach is acceptable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
CHANGELOG.md
(0 hunks)src/repositories/base.repository.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: ci / build-push / Build + Push Image
🔇 Additional comments (1)
src/repositories/base.repository.ts (1)
66-71
: LGTM! Well-implemented upsert method.The
upsert
method implementation is correct and follows established patterns:
- Properly wraps
updateOne
withupsert: true
option- Correctly spreads existing options to preserve any additional query options
- Maintains consistency with other repository methods
- Provides atomic create-or-update functionality as intended
This is a valuable addition to the repository that enables efficient upsert operations.
Summary by CodeRabbit
New Features
Chores