0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/server/models/member.js
Fabien O'Carroll c9b4fa4a09 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.
2019-09-25 10:05:30 +07:00

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)
};