mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
a62b014905
no-issue This is more specific and better if we start adding more stripe tables
32 lines
849 B
JavaScript
32 lines
849 B
JavaScript
const ghostBookshelf = require('./base');
|
|
|
|
const Member = ghostBookshelf.Model.extend({
|
|
tableName: 'members',
|
|
|
|
relationships: ['stripe_customers'],
|
|
relationshipBelongsTo: {
|
|
stripe_customers: 'members_stripe_customers'
|
|
},
|
|
|
|
permittedAttributes(...args) {
|
|
return ghostBookshelf.Model.prototype.permittedAttributes.apply(this, args).concat(this.relationships);
|
|
},
|
|
|
|
stripe_customers() {
|
|
return this.hasMany('MemberStripeCustomer', 'member_id');
|
|
}
|
|
}, {
|
|
permittedOptions(...args) {
|
|
return ghostBookshelf.Model.permittedOptions.apply(this, args).concat(['withRelated']);
|
|
}
|
|
});
|
|
|
|
const Members = ghostBookshelf.Collection.extend({
|
|
model: Member
|
|
});
|
|
|
|
module.exports = {
|
|
Member: ghostBookshelf.model('Member', Member),
|
|
Members: ghostBookshelf.collection('Members', Members)
|
|
};
|