Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2911,4 +2911,17 @@ describe('afterLogin hook', () => {
await Parse.User.logIn('testuser', 'p@ssword');
done();
});

it('should have access to context as save argument', async () => {
// Declare triggers
Parse.Cloud.beforeSave('TestObject', (req) => {
expect(req.context.a).toEqual('a');
});
Parse.Cloud.afterSave('TestObject', (req) => {
expect(req.context.a).toEqual('a');
});
// Save object
const obj = new TestObject();
await obj.save(null, { context: { a: 'a' } });
});
});
5 changes: 5 additions & 0 deletions src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function RestWrite(
}

if (!query) {
// Parse context
if (data._context && data._context instanceof Object) {
this.context = data._context;
delete data._context;
}
if (this.config.allowCustomObjectId) {
if (
Object.prototype.hasOwnProperty.call(data, 'objectId') &&
Expand Down