errorModel.js 917 Bytes
const model = require('../../../lib/model');
const mysqlPromise = require('../../../lib/mysql-apm');
const vars = require('./vars');

class errorModel extends model {
    constructor(ctx) {
        super(ctx);
        this.mysql = new mysqlPromise();
    }

    async getList(app, page, pageSize) {
        pageSize =  pageSize || 10;

        let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from error_report where app = ?', [app]).then(([r]) => r.count);
        let data = await this.mysql.query('SELECT id, app, type, preq_id, req_id, uid, udid, code, line, `column`, script, message, stack, create_time as time from error_report where app = ? order by create_time desc limit ?, ? ', [app, page, pageSize]).then(r => r.map(vars.handleItem));

        return {
            recordsTotal,
            recordsFiltered: recordsTotal,
            data
        }
    }
}

module.exports = errorModel;