diff --git a/server/homebrew.api.js b/server/homebrew.api.js index f531bdcf9..228a08128 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -319,6 +319,11 @@ If you believe you should have access to this brew, ask the file owner to invite } // Otherwise, save the brew with updated author list + // markModified() is necessary to have Mongoose reduce the array length in the database + // Without it, starting with an array of ['A', 'B', 'C'] in the database: + // - when reduced to ['A', 'B'] will result in ['A', 'B', 'C'] saved in the database + // - when reduced to ['B', 'C'] will result in ['B', 'C', 'C'] saved in the database + brew.markModified('authors'); await brew.save() .catch((err)=>{ throw { status: 500, message: err };