fix
This commit is contained in:
parent
cd21b345e4
commit
3fbc13e1b4
@ -13,7 +13,20 @@ export default {
|
||||
try {
|
||||
const limit = parseInt(req.query.limit) || 20;
|
||||
const offset = parseInt(req.query.offset) || 0;
|
||||
const result = await Subscriber.findAndCountAll({ limit, offset, order: [['id', 'ASC']] });
|
||||
const { status } = req.query;
|
||||
|
||||
// Создаем условия для фильтрации
|
||||
const where = {};
|
||||
if (status) {
|
||||
where.status = status;
|
||||
}
|
||||
|
||||
const result = await Subscriber.findAndCountAll({
|
||||
where,
|
||||
limit,
|
||||
offset,
|
||||
order: [['id', 'ASC']]
|
||||
});
|
||||
res.json({ count: result.count, rows: result.rows });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user