Skip to content

add context to Parse.Object.save#6626

Merged
acinader merged 4 commits into
parse-community:masterfrom
mtrezza:add-context-to-save
Apr 28, 2020
Merged

add context to Parse.Object.save#6626
acinader merged 4 commits into
parse-community:masterfrom
mtrezza:add-context-to-save

Conversation

@mtrezza

@mtrezza mtrezza commented Apr 18, 2020

Copy link
Copy Markdown
Member

Exposes the context object in Parse.Object.save() so that parameters can be made accessible in Cloud Code triggers beforeSave, afterSave.

Example:

const obj = new TestObject();
await obj.save(null, {context: {a: "a"}});

Parse.Cloud.beforeSave("TestObject", req => {
    console.log(req.context.a);
});

Parse.Cloud.afterSave("TestObject", req => {
    console.log(req.context.a);
});

Don't merge until

@acinader

Copy link
Copy Markdown
Contributor

seems useful to me and looks good. curious any thoughts you might have @davimacedo and @dplewis

if we merge, i can add to the PHP sdk

@mtrezza

mtrezza commented Apr 18, 2020

Copy link
Copy Markdown
Member Author

@acinader There is an open question regarding security when exposing the context to the client.

I added this question to #6459.
Let me know what you think. Maybe let's discuss there since it's a more visible thread.

@dplewis

dplewis commented Apr 28, 2020

Copy link
Copy Markdown
Member

@mtrezza The latest version of the SDK has been released and merged. You can update your branch and add the test cases.

@mtrezza

mtrezza commented Apr 28, 2020

Copy link
Copy Markdown
Member Author

@dplewis Great! Let's see if the tests pass 🤞

@codecov

codecov Bot commented Apr 28, 2020

Copy link
Copy Markdown

Codecov Report

Merging #6626 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6626   +/-   ##
=======================================
  Coverage   93.88%   93.88%           
=======================================
  Files         169      169           
  Lines       11991    11994    +3     
=======================================
+ Hits        11258    11261    +3     
  Misses        733      733           
Impacted Files Coverage Δ
src/RestWrite.js 93.67% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61546aa...51010fc. Read the comment docs.

@mtrezza

mtrezza commented Apr 28, 2020

Copy link
Copy Markdown
Member Author

@acinader ready for review

@uzaysan

uzaysan commented Oct 14, 2020

Copy link
Copy Markdown

How can we use master key with context?

Is this correct:
await obj.save(null, {context: {a: "a"}, useMasterKey: true});

@davimacedo

Copy link
Copy Markdown
Member

Yes. It should work.

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

Successfully merging this pull request may close these issues.

5 participants