Files
jambonz-api-server/lib/models/lcr-carrier-set-entry.js
Dave Horton 02806a109c added schema changes for LCR (#150)
* 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>
2023-05-05 20:09:34 -04:00

48 lines
990 B
JavaScript

const Model = require('./model');
const {promisePool} = require('../db');
class LcrCarrierSetEntry extends Model {
constructor() {
super();
}
static async retrieveAllByLcrRouteSid(sid) {
const sql = `SELECT * FROM ${this.table} WHERE lcr_route_sid = ? ORDER BY priority`;
const [rows] = await promisePool.query(sql, sid);
return rows;
}
static async deleteByLcrRouteSid(sid) {
const sql = `DELETE FROM ${this.table} WHERE lcr_route_sid = ?`;
const [rows] = await promisePool.query(sql, sid);
return rows.affectedRows;
}
}
LcrCarrierSetEntry.table = 'lcr_carrier_set_entry';
LcrCarrierSetEntry.fields = [
{
name: 'lcr_carrier_set_entry_sid',
type: 'string',
primaryKey: true
},
{
name: 'workload',
type: 'number'
},
{
name: 'lcr_route_sid',
type: 'string'
},
{
name: 'voip_carrier_sid',
type: 'string'
},
{
name: 'priority',
type: 'number'
}
];
module.exports = LcrCarrierSetEntry;