28 lines
548 B
JavaScript
28 lines
548 B
JavaScript
const Codes = require('../../../PG/model/codes')
|
|
|
|
async function getCodeListByTypeId(type_id) {
|
|
return type_id
|
|
? await Codes.query().where('type_id', type_id)
|
|
: await Codes.query()
|
|
}
|
|
|
|
async function getCodeById(id) {
|
|
return await Codes.query().findById(id)
|
|
}
|
|
|
|
async function addCode(code) {
|
|
return await Codes.query().insert(code)
|
|
}
|
|
|
|
async function updateCode(code) {
|
|
const { id } = code
|
|
return await Codes.query().patchAndFetchById(id, code)
|
|
}
|
|
|
|
module.exports = {
|
|
getCodeListByTypeId,
|
|
getCodeById,
|
|
addCode,
|
|
updateCode,
|
|
}
|