filo_caspar/api/schedule/model.mjs

36 lines
582 B
JavaScript
Raw Normal View History

import bookshelf from '../bookshelf.mjs'
import Graphic from '../graphic/model.mjs'
2018-06-26 18:35:12 +00:00
/* Schedule model:
{
id,
graphic_id,
values,
sort,
is_deleted,
}
*/
const Schedule = bookshelf.createModel({
tableName: 'schedule',
graphic() {
return this.belongsTo(Graphic, 'graphic_id')
},
format(attributes) {
attributes.values = JSON.stringify(attributes.values)
return attributes
},
parse(attributes) {
if (attributes.values) {
attributes.values = JSON.parse(attributes.values)
}
return attributes
},
}, {
})
export default Schedule