filo_caspar/server/io/store/model.js

25 lines
497 B
JavaScript
Raw Normal View History

2016-04-10 08:37:05 +00:00
import bookshelf from '../../bookshelf'
const Store = bookshelf.createModel({
tableName: 'store',
format(attributes) {
attributes.value = JSON.stringify(attributes.value)
return attributes
},
parse(attributes) {
attributes.value = JSON.parse(attributes.value)
return attributes
}
}, {
getSingle(name, withRelated = [], required = true) {
let where = { name }
return this.query({ where })
.fetch({ require, withRelated })
},
})
export default Store