This commit is contained in:
romantarkin 2025-08-18 10:39:28 +05:00
parent cd21b345e4
commit 3fbc13e1b4

View File

@ -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 });