Atomic transactions in cloud code

Hi,

I have seen PR request that transaction are now supported in REST api and some conversation about bugs in internal SDK, but have not found any examples or documentation.

So, my question in the subject line: how can I use transactions in the cloud code (MongoDB 4.2) ?

Thanks for any help!!!

You can get some inspiration from the test cases: https://github.com/parse-community/parse-server/blob/alpha/spec/batch.spec.js#L214

@davimacedo Thanks for reply, I have seen this code as part of PR, but what I see is only post requests with transaction: true, my question how can I do it cloud code ? (Doing posts from cloud code doesn’t seems reasonable for me :face_with_raised_eyebrow:)

The transaction option is not implemented in JS SDK yet. You can use the ParseServerRESTController to avoid the http request from Cloud Code: https://github.com/parse-community/parse-server/blob/a43638f3003f12793f72b7aa633c219fc061adc5/spec/ParseServerRESTController.spec.js#L138

ParseServerRESTController relays the “REST” request directly to Parse Server internals and that’s the class that the JS SDK uses within cloud code.