We have a React Native app that uses synchronised realm. The realm app in has triggers on insert to a ChangeLog collection. The triggers calls API of a third party solution to send any updates. The ChangeLog collection also serves the purpose of an audit log.
Documents in the ChangeLog collection represent any changes (mainly insert or update) to a set of business collections. These business collections are the main data source of the React Native app. ChangeLog collection is only a mechanism to push all changes to the main set of business collections preserving information for auditing.
As use takes actions in the React Native apps, new records are created or update in business collection and a corresponding change document is created in ChangeLog collection. This change is communicated through trigger → third party API
CHALLENGE: When device is offline, all change documents in ChangeLog collection stay on the device. There may be insert as well as updates on the records inserted. When the device comes back online, ChangeLog is synchronised with Atlas and insert trigger is fired for each document created in ChangeLog while offline. Since the triggers are asynchronous change documents for updates can potentially reach the target third party system before the change document for insert causing failure.
Is there out of the box way in MongoDB Atlas/Realm to send the triggers synchronously or at least send them in the order the records were originally inserted in the ChangeLog collection. It is guaranteed that change document for insert will be added to the collection before the one for update. All we need is to maintain the same order.