mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
31 lines
721 B
JavaScript
31 lines
721 B
JavaScript
|
const ghostBookshelf = require('./base');
|
||
|
|
||
|
const EmailBatch = ghostBookshelf.Model.extend({
|
||
|
tableName: 'email_batches',
|
||
|
|
||
|
defaults() {
|
||
|
return {
|
||
|
status: 'pending'
|
||
|
};
|
||
|
},
|
||
|
|
||
|
email() {
|
||
|
return this.belongsTo('Email', 'email_id');
|
||
|
},
|
||
|
recipients() {
|
||
|
return this.hasMany('EmailRecipient', 'batch_id');
|
||
|
},
|
||
|
members() {
|
||
|
return this.belongsToMany('Member', 'email_recipients', 'batch_id', 'member_id');
|
||
|
}
|
||
|
});
|
||
|
|
||
|
const EmailBatches = ghostBookshelf.Collection.extend({
|
||
|
model: EmailBatch
|
||
|
});
|
||
|
|
||
|
module.exports = {
|
||
|
EmailBatch: ghostBookshelf.model('EmailBatch', EmailBatch),
|
||
|
EmailBatches: ghostBookshelf.model('EmailBatches', EmailBatches)
|
||
|
};
|