mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
* added schema changes for LCR * fix FK * first draft * force drop table * add testcases * swagger updated * update code * wip: add service provider LCR * fix userpermission on lcr * add lcr.is_active * remove FK constraints on lcr * wip * wip * wip * fix: review comments * fix: final review * fix: final review * fix: update database schema * fix: update database schema * fix: update database schema * update schema * fix: review comments * lcr_routes.priority should not be unique * fix review comments --------- Co-authored-by: Quan HL <quan.luuhoang8@gmail.com>
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
const Model = require('./model');
|
|
const {promisePool} = require('../db');
|
|
|
|
|
|
class LcrRoutes extends Model {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
static async retrieveAllByLcrSid(sid) {
|
|
const sql = `SELECT * FROM ${this.table} WHERE lcr_sid = ? ORDER BY priority`;
|
|
const [rows] = await promisePool.query(sql, sid);
|
|
return rows;
|
|
}
|
|
|
|
static async deleteByLcrSid(sid) {
|
|
const sql = `DELETE FROM ${this.table} WHERE lcr_sid = ?`;
|
|
const [rows] = await promisePool.query(sql, sid);
|
|
return rows.affectedRows;
|
|
}
|
|
|
|
static async countAllByLcrSid(sid) {
|
|
const sql = `SELECT COUNT(*) AS count FROM ${this.table} WHERE lcr_sid = ?`;
|
|
const [rows] = await promisePool.query(sql, sid);
|
|
return rows.length ? rows[0].count : 0;
|
|
}
|
|
}
|
|
|
|
LcrRoutes.table = 'lcr_routes';
|
|
LcrRoutes.fields = [
|
|
{
|
|
name: 'lcr_route_sid',
|
|
type: 'string',
|
|
primaryKey: true
|
|
},
|
|
{
|
|
name: 'lcr_sid',
|
|
type: 'string'
|
|
},
|
|
{
|
|
name: 'regex',
|
|
type: 'string'
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'string'
|
|
},
|
|
{
|
|
name: 'priority',
|
|
type: 'number'
|
|
}
|
|
];
|
|
|
|
module.exports = LcrRoutes;
|