WIP message-processor: building the message

This commit is contained in:
Juan Tejada 2016-06-21 17:15:42 -07:00
parent b4e05fcb30
commit 2170ee4143
3 changed files with 14 additions and 10 deletions

View file

@ -8,6 +8,7 @@ const STORAGE_DIR = path.join(__base, 'storage');
if (!fs.existsSync(STORAGE_DIR)) {
fs.mkdirSync(STORAGE_DIR);
}
Object.assign(Sequelize, require('./database-connection-types')(Sequelize))
class DatabaseConnectionFactory {
constructor() {

12
core/database-types.js Normal file
View file

@ -0,0 +1,12 @@
module.exports = (Sequelize) => ({
JSONTYPE: (fieldName) => ({
type: Sequelize.STRING,
defaultValue: '{}',
get: function get() {
return JSON.parse(this.getDataValue('syncState'))
},
set: function set(val) {
this.setDataValue('syncState', JSON.stringify(val));
},
}),
})

View file

@ -2,16 +2,7 @@ module.exports = (sequelize, Sequelize) => {
const Category = sequelize.define('Category', {
name: Sequelize.STRING,
role: Sequelize.STRING,
syncState: {
type: Sequelize.STRING,
defaultValue: '{}',
get: function get() {
return JSON.parse(this.getDataValue('syncState'))
},
set: function set(val) {
this.setDataValue('syncState', JSON.stringify(val));
},
},
syncState: Sequelize.JSONTYPE('syncState'),
}, {
classMethods: {
associate: ({Message}) => {