Add ctx.isNewInstance for "save" hooks#515
Merged
Merged
Conversation
"before save" hooks provide "ctx.isNewInstance" whenever "ctx.instance" is set. Possible values: - true for all CREATE operations - false for all UPDATE operations - undefined for "prototype.save" "after save" hooks provide "ctx.isNewInstance" whenever "ctx.instance" is set. Possible values: - true after all CREATE operations - false after all UPDATE operations - undefined after "updateOrCreate" and "save" Note: both "updateOrCreate" and "prototype.updateAttributes" don't provide `ctx.instance` to "before save" hooks, therefore `ctx.isNewInstance` it not provided either.
Member
Author
|
I'll need to update this PR if #516 is landed first. |
Contributor
|
LGTM |
Contributor
|
LGTM. As a general note, I don't like the fact that we overload the same property names for I'm fine to land this PR as is and leave the general concerns to be addressed in future design refinements. |
bajtos
added a commit
that referenced
this pull request
Mar 20, 2015
Add ctx.isNewInstance for "save" hooks
This was referenced Mar 20, 2015
Member
Author
|
@crandmck could you please update the "Operations hooks" docs page? |
Contributor
|
Added #526 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
"before save" hooks provide "ctx.isNewInstance" whenever "ctx.instance" is set. Possible values:
"after save" hooks provide "ctx.isNewInstance" whenever "ctx.instance" is set. Possible values:
Note: both "updateOrCreate" and "prototype.updateAttributes" don't provide
ctx.instanceto "before save" hooks, thereforectx.isNewInstanceit not provided either.Connect to strongloop/loopback#838
/to @raymondfeng please review
/cc @fabien @clarkorz
Note that we will need to implement this feature in other connectors too, but unfortunately I don't have bandwidth for that now.