Compare commits
2 commits
6454f5f8d6
...
d03394bee7
Author | SHA1 | Date | |
---|---|---|---|
d03394bee7 | |||
4da4dd9423 |
3 changed files with 12 additions and 13 deletions
|
@ -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 });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -196,19 +196,19 @@
|
|||
|
||||
let url = `/api/v1/albums?userId=${this.userId}&page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
|
||||
if ( this.artist ) {
|
||||
url += `&artists_sort=${this.artist}`;
|
||||
url += `&artists_sort=${this.artist.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.format ) {
|
||||
url += `&format=${this.format}`;
|
||||
url += `&format=${this.format.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.year ) {
|
||||
url += `&year=${this.year}`;
|
||||
}
|
||||
if ( this.genre ) {
|
||||
url += `&genre=${this.genre}`;
|
||||
url += `&genre=${this.genre.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.style ) {
|
||||
url += `&style=${this.style}`;
|
||||
url += `&style=${this.style.replace('&', '%26')}`;
|
||||
}
|
||||
|
||||
axios.get(url)
|
||||
|
|
|
@ -250,19 +250,19 @@
|
|||
|
||||
let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
|
||||
if ( this.artist ) {
|
||||
url += `&artists_sort=${this.artist}`;
|
||||
url += `&artists_sort=${this.artist.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.format ) {
|
||||
url += `&format=${this.format}`;
|
||||
url += `&format=${this.format.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.year ) {
|
||||
url += `&year=${this.year}`;
|
||||
}
|
||||
if ( this.genre ) {
|
||||
url += `&genre=${this.genre}`;
|
||||
url += `&genre=${this.genre.replace('&', '%26')}`;
|
||||
}
|
||||
if ( this.style ) {
|
||||
url += `&style=${this.style}`;
|
||||
url += `&style=${this.style.replace('&', '%26')}`;
|
||||
}
|
||||
|
||||
axios.get(url)
|
||||
|
|
Loading…
Reference in a new issue