2021-08-23 15:10:12 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
|
|
|
const tpl = require('@tryghost/tpl');
|
|
|
|
const ghostBookshelf = require('./base');
|
|
|
|
|
|
|
|
const messages = {
|
|
|
|
cannotPerformAction: 'Cannot {action} MemberProductEvent'
|
|
|
|
};
|
|
|
|
|
|
|
|
const MemberProductEvent = ghostBookshelf.Model.extend({
|
|
|
|
tableName: 'members_product_events',
|
|
|
|
|
|
|
|
member() {
|
|
|
|
return this.belongsTo('Member', 'member_id', 'id');
|
|
|
|
},
|
|
|
|
|
|
|
|
product() {
|
|
|
|
return this.belongsTo('Product', 'product_id', 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
}, {
|
|
|
|
async edit() {
|
2021-12-01 14:22:14 +03:00
|
|
|
throw new errors.IncorrectUsageError({
|
|
|
|
message: tpl(messages.cannotPerformAction, 'edit')
|
|
|
|
});
|
2021-08-23 15:10:12 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
async destroy() {
|
2021-12-01 14:22:14 +03:00
|
|
|
throw new errors.IncorrectUsageError({
|
|
|
|
message: tpl(messages.cannotPerformAction, 'destroy')
|
|
|
|
});
|
2021-08-23 15:10:12 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const MemberProductEvents = ghostBookshelf.Collection.extend({
|
|
|
|
model: MemberProductEvent
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
MemberProductEvent: ghostBookshelf.model('MemberProductEvent', MemberProductEvent),
|
|
|
|
MemberProductEvents: ghostBookshelf.collection('MemberProductEvents', MemberProductEvents)
|
|
|
|
};
|