mailtrain/models/lists.js
Tomas Bures d63eed9ca9 Reports ported to ReactJS and Knex
Note that the interface for the custom JS code inside a report template has changed. It now offers promise-based interface and exposes knex.
2017-07-13 13:27:03 +02:00

24 lines
No EOL
604 B
JavaScript

'use strict';
const knex = require('../lib/knex');
const dtHelpers = require('../lib/dt-helpers');
const interoperableErrors = require('../shared/interoperable-errors');
async function listDTAjax(params) {
return await dtHelpers.ajaxList(params, tx => tx('lists'), ['lists.id', 'lists.name', 'lists.cid', 'lists.subscribers', 'lists.description']);
}
async function getById(id) {
const entity = await knex('lists').where('id', id).first();
if (!entity) {
throw new interoperableErrors.NotFoundError();
}
return entity;
}
module.exports = {
listDTAjax,
getById
};