mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 14:12:40 +00:00
Add markModified to fix authors array in DB
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user