Mailspring/core/models/shared/account.js

31 lines
713 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
module.exports = (sequelize, Sequelize) => {
const Account = sequelize.define('Account', {
emailAddress: Sequelize.STRING,
2016-06-21 08:33:23 +08:00
syncPolicy: {
type: Sequelize.STRING,
get: function get() {
return JSON.parse(this.getDataValue('syncPolicy'))
},
set: function set(val) {
this.setDataValue('syncPolicy', JSON.stringify(val));
},
},
2016-06-19 18:02:32 +08:00
}, {
classMethods: {
associate: ({AccountToken}) => {
Account.hasMany(AccountToken, {as: 'tokens'})
},
},
instanceMethods: {
toJSON: function toJSON() {
return {
id: this.id,
email_address: this.emailAddress,
}
},
},
});
return Account;
};