Skip to content

Commit 5fc9ba4

Browse files
fix(tasks): use document .save() instead of new Model() in repository update (#3440)
* fix(tasks): use document .save() instead of new Model() in repository 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 * fix(tasks): update JSDoc param type for update() to reflect Mongoose document requirement
1 parent 87a4553 commit 5fc9ba4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/tasks/repositories/tasks.repository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const get = (id) => {
4242
/**
4343
* @function update
4444
* @description Data access operation to update an existing task in the database.
45-
* @param {Object} task - The task object containing the updated details.
45+
* @param {import('mongoose').Document} task - The hydrated Mongoose Task document to update. Must support `.save()`.
4646
* @returns {Object} The updated task.
4747
*/
48-
const update = (task) => new Task(task).save().then((doc) => doc.populate(defaultPopulate));
48+
const update = (task) => task.save().then((doc) => doc.populate(defaultPopulate));
4949

5050
/**
5151
* @function remove

0 commit comments

Comments
 (0)