mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
865366c7c8
no issue - the event chain works like this: - if a model registers an event, it get's triggered, because it's stronger than the base model - but you have to call the base model to agree on a contract, because base model implements generic logic in event handlers - this was inconsistently used
29 lines
822 B
JavaScript
29 lines
822 B
JavaScript
const ghostBookshelf = require('./base'),
|
|
Basetoken = require('./base/token');
|
|
|
|
let Accesstoken,
|
|
Accesstokens;
|
|
|
|
Accesstoken = Basetoken.extend({
|
|
tableName: 'accesstokens',
|
|
|
|
emitChange: function emitChange(event, options) {
|
|
const eventToTrigger = 'token' + '.' + event;
|
|
ghostBookshelf.Model.prototype.emitChange.bind(this)(this, eventToTrigger, options);
|
|
},
|
|
|
|
onCreated: function onCreated(model, attrs, options) {
|
|
ghostBookshelf.Model.prototype.onCreated.apply(this, arguments);
|
|
model.emitChange('added', options);
|
|
}
|
|
});
|
|
|
|
Accesstokens = ghostBookshelf.Collection.extend({
|
|
model: Accesstoken
|
|
});
|
|
|
|
module.exports = {
|
|
Accesstoken: ghostBookshelf.model('Accesstoken', Accesstoken),
|
|
Accesstokens: ghostBookshelf.collection('Accesstokens', Accesstokens)
|
|
};
|