2016-06-19 18:02:32 +08:00
|
|
|
module.exports = (sequelize, Sequelize) => {
|
|
|
|
const MessageUID = sequelize.define('MessageUID', {
|
|
|
|
uid: Sequelize.STRING,
|
2016-06-21 05:44:02 +08:00
|
|
|
messageHash: Sequelize.STRING,
|
2016-06-20 15:19:16 +08:00
|
|
|
flags: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
get: function get() {
|
|
|
|
return JSON.parse(this.getDataValue('flags'))
|
|
|
|
},
|
|
|
|
set: function set(val) {
|
|
|
|
this.setDataValue('flags', JSON.stringify(val));
|
|
|
|
},
|
|
|
|
},
|
2016-06-19 18:02:32 +08:00
|
|
|
}, {
|
2016-06-20 15:19:16 +08:00
|
|
|
indexes: [
|
|
|
|
{
|
|
|
|
unique: true,
|
2016-06-21 05:44:02 +08:00
|
|
|
fields: ['uid', 'CategoryId', 'messageHash'],
|
|
|
|
},
|
2016-06-20 15:19:16 +08:00
|
|
|
],
|
2016-06-19 18:02:32 +08:00
|
|
|
classMethods: {
|
2016-06-21 05:44:02 +08:00
|
|
|
associate: ({Category}) => {
|
2016-06-19 18:02:32 +08:00
|
|
|
MessageUID.belongsTo(Category)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return MessageUID;
|
|
|
|
};
|