mdb to bulma + view my collection

This commit is contained in:
Damien Broqua 2022-02-15 16:45:14 +01:00
parent f08e70eb7c
commit 68fa736a91
21 changed files with 617 additions and 292 deletions

View file

@ -73,13 +73,49 @@ class Albums extends Pages {
discogsId: body.id,
User: user._id,
};
data.released = moment(data.released.replace("-00", "-01"));
data.released = data.released
? moment(data.released.replace("-00", "-01"))
: null;
delete data.id;
const album = new AlbumsModel(data);
return album.save();
}
async getAll() {
const {
page = 1,
limit = 4,
sort = "artists_sort",
order = "asc",
} = this.req.query;
const skip = (page - 1) * limit;
const count = await AlbumsModel.count({
user: this.req.user._id,
});
const rows = await AlbumsModel.find(
{
user: this.req.user._id,
},
[],
{
skip,
limit,
sort: {
[sort]: order.toLowerCase() === "asc" ? 1 : -1,
},
}
);
return {
rows,
count,
};
}
}
export default Albums;