parse-mockdb icon indicating copy to clipboard operation
parse-mockdb copied to clipboard

How do I access to beforeSave's request and response objects?

Open hokster7 opened this issue 10 years ago • 1 comments

It looks like ParseMockDB.registerHook expects a promise, even though regular Cloud Code beforeX handlers are of type function(request,response). ~~The contract should be identical to Cloud Code's for fidelity.~~ callbacks are a pain!

EDIT: Okay, instead of function(request,response), how about we replace the response part with promise syntax, but leave the request as a parameter: i.e. function(request).

Check the Parse.Object docs. Most *Request types are the same as each other and the *Response types are the same as each other too:

Parse.Cloud.AfterDeleteRequest Parse.Cloud.AfterSaveRequest Parse.Cloud.BeforeDeleteRequest Parse.Cloud.BeforeDeleteResponse Parse.Cloud.BeforeSaveRequest Parse.Cloud.BeforeSaveResponse

Note: some assumptions have to be made about the masterKey.

hokster7 avatar Dec 10 '15 16:12 hokster7

+1, following:

Parse.Cloud.AfterDeleteRequest Parse.Cloud.AfterSaveRequest Parse.Cloud.BeforeDeleteRequest Parse.Cloud.BeforeDeleteResponse Parse.Cloud.BeforeSaveRequest Parse.Cloud.BeforeSaveResponse

yutin1987 avatar Dec 12 '15 16:12 yutin1987