Mailspring/core/models/account/message_uid.js

30 lines
662 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
module.exports = (sequelize, Sequelize) => {
const MessageUID = sequelize.define('MessageUID', {
uid: Sequelize.STRING,
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,
fields: ['uid', 'CategoryId', 'messageHash'],
},
2016-06-20 15:19:16 +08:00
],
2016-06-19 18:02:32 +08:00
classMethods: {
associate: ({Category}) => {
2016-06-19 18:02:32 +08:00
MessageUID.belongsTo(Category)
},
},
});
return MessageUID;
};