Issue #113: Model.create ignoring field and virtual setters #114
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR solves the problem by making the behaviour of feathers-sequelize's
raw
parameter consistent across service methods and take priority over the behaviour of sequelize'sraw
parameter for Model.create calls (in whichraw
means something completely different). It introduces asequelize.ignoreSetters
argument to control the shadowed Model.createraw
parameter.Without this PR, the following behaviour is observed:
service.create(data)
— setters ignoredservice.create(data, {raw: false})
— setters called, but DAO returnedThe desired default behaviour is to have setters called but JSON returned, which this PR achieves. To get the native behaviour of calling
Model.create({raw: true})
, you can now call:service.create(data, {sequelize: {ignoreSetters: true}})
This PR should be accompanied by a corresponding update to the docs to describe the new
ignoreSetters
argument: https://docs.feathersjs.com/api/databases/sequelize.html