Added pagination size

This commit is contained in:
Damien Broqua 2024-02-01 08:47:33 +01:00
parent d4e6d23459
commit bf2e9be3b7
11 changed files with 54 additions and 17 deletions

View file

@ -192,7 +192,6 @@ Publié automatiquement via #musictopus`;
async getAll() {
const {
page,
limit,
exportFormat = "json",
sort = "artists_sort",
order = "asc",
@ -206,6 +205,8 @@ Publié automatiquement via #musictopus`;
discogsId,
} = this.req.query;
const limit = this.req.user?.pagination || 16;
let userId = this.req.user?._id;
const where = {};
@ -303,6 +304,7 @@ Publié automatiquement via #musictopus`;
default:
return {
rows,
limit,
count,
};
}

View file

@ -16,6 +16,7 @@ class Me extends Pages {
const { _id } = this.req.user;
const schema = Joi.object({
pagination: Joi.number(),
isPublicCollection: Joi.boolean(),
oldPassword: Joi.string(),
password: Joi.string(),
@ -45,6 +46,10 @@ class Me extends Pages {
user.salt = value.password;
}
if (value.pagination) {
user.pagination = value.pagination;
}
if (value.isPublicCollection !== undefined) {
user.isPublicCollection = value.isPublicCollection;
}

View file

@ -25,6 +25,10 @@ const UserSchema = new mongoose.Schema(
},
hash: String,
salt: String,
pagination: {
type: Number,
default: 16,
},
isPublicCollection: {
type: Boolean,
default: false,