Skip to content

request.original in afterSave handler gone #5167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markuswinkler opened this issue Nov 9, 2018 · 7 comments
Closed

request.original in afterSave handler gone #5167

markuswinkler opened this issue Nov 9, 2018 · 7 comments

Comments

@markuswinkler
Copy link

Issue Description

I have an afterSave handler that uses request.original data to check if a field truly has changed.

Steps to reproduce

try to access request.original

Expected Results

access to request.original

Actual Outcome

request.original is undefined

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 3.0.0
    • Operating System: macOS
    • Hardware: mac
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.4.13
    • Storage engine: wired tiger
    • Hardware: -
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): localhost

Logs/Trace

@flovilmart
Copy link
Contributor

Can you point out a commit that would have removed this feature?

@markuswinkler
Copy link
Author

It disappeared when I switched from 2.8.4 to 3.0.0

flovilmart added a commit that referenced this issue Nov 11, 2018
@flovilmart
Copy link
Contributor

I just tried to reproduce it with this #5170 and it behaves as expected. The original object is only present on updates (as written in RestWrite.js).

@markuswinkler
Copy link
Author

ah! my bad. I didn't know that the original is only there in that case.
Funny enough though I never had the problem before that.
Is afterSave not in general called after every save?
Can I safely assume that original is there every time the content has changed?

@flovilmart
Copy link
Contributor

It should be there whenever there was an original object in the DB ‘before’ the save call enters I.e. when the object is updated, not when it is created.

@markuswinkler
Copy link
Author

Thank you for the clarification.

@flovilmart
Copy link
Contributor

You’re welcome, in doubt, the code is is RestWrite.js, and should be quite straight forward when it comes to hooks. Another part is in triggers.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants