#60 - Bug au refresh d'un album
This commit is contained in:
parent
4da4dd9423
commit
d03394bee7
1 changed files with 4 additions and 5 deletions
|
@ -191,10 +191,11 @@ class Albums extends Pages {
|
||||||
async patchOne() {
|
async patchOne() {
|
||||||
const { itemId: _id } = this.req.params;
|
const { itemId: _id } = this.req.params;
|
||||||
const { _id: User } = this.req.user;
|
const { _id: User } = this.req.user;
|
||||||
const album = await AlbumsModel.findOne({
|
const query = {
|
||||||
_id,
|
_id,
|
||||||
User,
|
User,
|
||||||
});
|
};
|
||||||
|
const album = await AlbumsModel.findOne(query);
|
||||||
|
|
||||||
if (!album) {
|
if (!album) {
|
||||||
throw new ErrorEvent(
|
throw new ErrorEvent(
|
||||||
|
@ -206,9 +207,7 @@ class Albums extends Pages {
|
||||||
|
|
||||||
const values = await getAlbumDetails(album.discogsId);
|
const values = await getAlbumDetails(album.discogsId);
|
||||||
|
|
||||||
await album.updateOne(values);
|
return AlbumsModel.findOneAndUpdate(query, values, { new: true });
|
||||||
|
|
||||||
return album;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue