mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
0fd0527da0
no-issue
31 lines
726 B
JavaScript
31 lines
726 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.collection('EmailBatches', EmailBatches)
|
|
};
|