Mailspring/packages/nylas-core/models/account/label.js

29 lines
730 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
module.exports = (sequelize, Sequelize) => {
const Label = sequelize.define('label', {
accountId: { type: Sequelize.STRING, allowNull: false },
version: Sequelize.INTEGER,
2016-06-19 18:02:32 +08:00
name: Sequelize.STRING,
role: Sequelize.STRING,
}, {
classMethods: {
associate: ({Message, Thread}) => {
Label.belongsToMany(Message, {through: 'message_labels'})
Label.belongsToMany(Thread, {through: 'thread_labels'})
2016-06-19 18:02:32 +08:00
},
},
2016-06-23 05:17:45 +08:00
instanceMethods: {
toJSON: function toJSON() {
return {
id: this.id,
account_id: this.accountId,
object: 'label',
2016-06-23 05:17:45 +08:00
name: this.role,
display_name: this.name,
};
},
},
2016-06-19 18:02:32 +08:00
});
return Label;
2016-06-19 18:02:32 +08:00
};