mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-11-08 07:21:18 +08:00
35 lines
867 B
JavaScript
35 lines
867 B
JavaScript
const {JSONType} = require('../../database-types');
|
|
|
|
module.exports = (sequelize, Sequelize) => {
|
|
return sequelize.define('folder', {
|
|
accountId: { type: Sequelize.STRING, allowNull: false },
|
|
version: Sequelize.INTEGER,
|
|
name: Sequelize.STRING,
|
|
role: Sequelize.STRING,
|
|
syncState: JSONType('syncState'),
|
|
}, {
|
|
indexes: [
|
|
{
|
|
unique: true,
|
|
fields: ['role'],
|
|
},
|
|
],
|
|
classMethods: {
|
|
associate: ({Folder, Message, Thread}) => {
|
|
Folder.hasMany(Message)
|
|
Folder.belongsToMany(Thread, {through: 'thread_folders'})
|
|
},
|
|
},
|
|
instanceMethods: {
|
|
toJSON: function toJSON() {
|
|
return {
|
|
id: `${this.id}`,
|
|
account_id: this.accountId,
|
|
object: 'folder',
|
|
name: this.role,
|
|
display_name: this.name,
|
|
};
|
|
},
|
|
},
|
|
});
|
|
};
|