core/server/models/post.js
function onSaved(model, response, options) {
        ghostBookshelf.Model.prototype.onSaved.apply(this, arguments);

        if (options.method !== 'insert') {
            return;
        }

        var status = model.get('status');

        model.emitChange('added', options);

        if (['published', 'scheduled'].indexOf(status) !== -1) {
            model.emitChange(status, options);
        }
    }
function onSaved(model, response, options) {
        ghostBookshelf.Model.prototype.onSaved.apply(this, arguments);

        if (options.method !== 'insert') {
            return;
        }

        var status = model.get('status');

        model.emitChange('added', options);

        if (['published', 'scheduled'].indexOf(status) !== -1) {
            model.emitChange(status, options);
        }
    }
function onSaved ( model , response , options ) { ghostBookshelf . Model . prototype . onSaved . apply ( this , arguments ) ; if ( options . method !== 'insert' ) { return ; } var status = model . get ( 'status' ) ; model . emitChange ( 'added' , options ) ; if ( [ 'published' , 'scheduled' ] . indexOf ( status ) !== - 1 ) { model . emitChange ( status , options ) ; } }
We update the tags after the Post was inserted.
We update the tags before the Post was updated, see `onSaving` event.
`onCreated` is called before `onSaved`.

`onSaved` is the last event in the line - triggered for updating or inserting data.
bookshelf-relations listens on `created` + `updated`.
We ensure that we are catching the event after bookshelf relations.
We update the tags after the Post was inserted . We update the tags before the Post was updated see onSaving event . onCreated is called before onSaved .