Skip to content

Commit

Permalink
Removed taking care of bookshelf's changed model keys
Browse files Browse the repository at this point in the history
no issue

- this is no longer needed for now
- it was anyway a little bit ugly to modify bookshelf's `changed` object
- if we want to change something about figuring out if a model has changed (including relations)
  -> we probably need to override bookshelf
  • Loading branch information
kirrg001 committed Apr 5, 2018
1 parent 853b518 commit da80019
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions core/server/models/base/index.js
Expand Up @@ -180,18 +180,6 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
this.attributes = this.pick(this.permittedAttributes());
// Store the previous attributes so we can tell what was updated later
this._updatedAttributes = newObj.previousAttributes();

/**
* Bookshelf keeps none valid model attributes in `model.changed`. This causes problems
* when detecting if a model has changed. Bookshelf detects changed attributes too early.
* So we have to manually remove invalid model attributes from this object.
*
* e.g. if you pass `tag.parent` into the model layer, but the value has not changed,
* the attribute (`tag.parent`) is still kept in the `changed` object. This is wrong.
*
* TLDR; only keep valid model attributes in the changed object
*/
this.changed = _.pick(this.changed, Object.keys(this.attributes));
},

/**
Expand Down

0 comments on commit da80019

Please sign in to comment.