#60 - Bug au refresh d'un album

This commit is contained in:
Damien Broqua 2022-09-14 14:45:22 +02:00
parent 4da4dd9423
commit d03394bee7

View file

@ -191,10 +191,11 @@ class Albums extends Pages {
async patchOne() {
const { itemId: _id } = this.req.params;
const { _id: User } = this.req.user;
const album = await AlbumsModel.findOne({
const query = {
_id,
User,
});
};
const album = await AlbumsModel.findOne(query);
if (!album) {
throw new ErrorEvent(
@ -206,9 +207,7 @@ class Albums extends Pages {
const values = await getAlbumDetails(album.discogsId);
await album.updateOne(values);
return album;
return AlbumsModel.findOneAndUpdate(query, values, { new: true });
}
/**