0
0
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:
G.Ambatte
2023-02-17 11:26:11 +13:00
parent d9f5e9d635
commit 4b98c1ac89

View File

@@ -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 };