add context to Parse.Object.save (#6626)
* added failing test * added parsing of context in REST save request * undo lint changes
This commit is contained in:
@@ -2911,4 +2911,17 @@ describe('afterLogin hook', () => {
|
|||||||
await Parse.User.logIn('testuser', 'p@ssword');
|
await Parse.User.logIn('testuser', 'p@ssword');
|
||||||
done();
|
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' } });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ function RestWrite(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
|
// Parse context
|
||||||
|
if (data._context && data._context instanceof Object) {
|
||||||
|
this.context = data._context;
|
||||||
|
delete data._context;
|
||||||
|
}
|
||||||
if (this.config.allowCustomObjectId) {
|
if (this.config.allowCustomObjectId) {
|
||||||
if (
|
if (
|
||||||
Object.prototype.hasOwnProperty.call(data, 'objectId') &&
|
Object.prototype.hasOwnProperty.call(data, 'objectId') &&
|
||||||
|
|||||||
Reference in New Issue
Block a user