Updated Member model to handle stripe_info property

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.
This commit is contained in:
Fabien O'Carroll 2019-09-19 11:50:55 +08:00
parent e54adfd30d
commit c9b4fa4a09

View File

@ -1,7 +1,24 @@
const ghostBookshelf = require('./base');
const Member = ghostBookshelf.Model.extend({
tableName: 'members'
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({