Skip to content
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

beforeSave issues with dirtyKeys #31

Closed
Silkjaer opened this issue Sep 30, 2015 · 4 comments
Closed

beforeSave issues with dirtyKeys #31

Silkjaer opened this issue Sep 30, 2015 · 4 comments

Comments

@Silkjaer
Copy link

I am running my CloudCode on a node.js server, using webhooks as described in a recent blog post on parse.com, and using CloudCode-Express.

Everything seems to run smooth, however in my beforeSave triggers I need to check if certain keys are dirty and they never are?

Parse.Cloud.beforeSave("CLASSNAME", function(request, response) {
    console.log(request.object.dirtyKeys()); // always outputs an empty array to the console
    if(request.object.dirty("key") && request.object.get("key")) { // value is a boolean
        // never executes
    }
});

Is this a bug, or am I doing something wrong? Running the same triggers on CloudCode on Parse.com (non-self-hosted), works as expected.

@stanleyw
Copy link
Contributor

Currently this is not supported by webhooks. The dirty keys are not passed to webhooks by the Parse backend according to the current spec (https://www.parse.com/docs/js/guide#cloud-code-advanced-beforesave-webhooks), so the JS SDK can't populate this field in Node.js.

However, we are always looking to improve the platform. Could you talk more about your use case and why you need this information?

@Silkjaer
Copy link
Author

Thanks for the reference, I was looking all over for this.

I am relying on some node.js plugins that I can't implement in CloudCode, so I made a quick decision to move all code to Heroku (without noticing the dirtyKeys limitation). I want to avoid maintaining server side logic in too many places :)

I am often using the change of a key's value as a trigger to another action, e.g. updating a related object. I do not want to trigger these actions on every save, but only if a specific key's value is changed.

I am also validating keys if they are dirty, e.g. to set a default value or verify it is not undefined.

Would it be possible to somehow trigger a warning log message if unsupported functions are used?

Thanks!

On 30. sep. 2015, at 19.11, Stanley Wang notifications@github.com wrote:

Currently this is not supported by webhooks. The dirty keys are not passed to webhooks by the Parse backend according to the current spec (https://www.parse.com/docs/js/guide#cloud-code-advanced-beforesave-webhooks), so the JS SDK can't populate this field in Node.js.

However, we are always looking to improve the platform. Could you talk more about your use case and why you need this information?


Reply to this email directly or view it on GitHub.

@andrewimm
Copy link
Contributor

@Zicker are you referring to code running in Node.js, or on Parse Cloud Code?
This issue is regarding code running on a privately hosted Node server, using our Webhooks service.

That said, the behavior you mention should still be supported in 1.6. We have tests that suggest it works in the current version (1.6.4)

@stanleyw
Copy link
Contributor

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

3 participants