fix(tasks): use document .save() instead of new Model() in repository update#3440
Conversation
… update Prevents duplicate document creation when the update function receives a mongoose document without a recognized _id or with isNew still set. Aligns tasks repository with the pattern already used by organizations and memberships repositories. Closes #3433
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 15 minutes and 27 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdated the repository update operation to persist the provided Mongoose document instance via Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the tasks repository update behavior to persist changes via the existing Mongoose document instance, preventing accidental duplicate task creation during updates and aligning with the safer repository pattern used elsewhere.
Changes:
- Replace
new Task(task).save()withtask.save()inTasksRepository.update(). - Continue to populate default relations after persistence.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3440 +/- ##
=======================================
Coverage 85.51% 85.51%
=======================================
Files 113 113
Lines 2879 2879
Branches 795 795
=======================================
Hits 2462 2462
Misses 331 331
Partials 86 86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…document requirement
Summary
new Task(task).save()withtask.save()intasks.repository.jsupdate function to prevent duplicate document creation when the mongoose document's_idis not recognized orisNewis still setTest plan
should be able to create, update, and delete his own taskpassesCloses #3433
Summary by CodeRabbit