mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
c9b4fa4a09
no-issue This maps the stripe_info property to the MemberStripeInfo model, so that we can update the member model, and correctly add/edit rows in the members-stripe-info table.
31 lines
825 B
JavaScript
31 lines
825 B
JavaScript
const ghostBookshelf = require('./base');
|
|
|
|
const Member = ghostBookshelf.Model.extend({
|
|
tableName: 'members',
|
|
|
|
relationships: ['stripe_info'],
|
|
relationshipBelongsTo: {
|
|
stripe_info: 'members_stripe_info'
|
|
},
|
|
|
|
permittedAttributes(...args) {
|
|
return ghostBookshelf.Model.prototype.permittedAttributes.apply(this, args).concat(this.relationships);
|
|
},
|
|
|
|
stripe_info() {
|
|
return this.hasMany('MemberStripeInfo', '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)
|
|
};
|