Has anyone got multi-document ACID transactions to work in Meteor?

Multi-document ACID transactions were announced with MongoDb 4.0 was announced 6 months ago (see here: MongoDB 4.0 and related announcements). See also this article for Background info

If I do understand the various issues that have been reported it’s not yet implemented fully, eg the “startSession()” is one of the problems.

So my questions are:

  1. Has anyone managed to find a workaround and get the multi-document feature to work in Meteor?

  2. Is there a date for implementation of this new feature and a definite commitment from MDG to implement this?

I refer to eg the following closed issue: Upgrade to MongoDB 4.0 #269 for further reading, more references to issues are in that issue.


You can get a reference to the MongoClient instance that is created by Meteor’s mongo package and then call the transaction functions (e.g., startSession and commitTransaction) using this client:

import { MongoInternals } from "meteor/mongo";

const { client } = MongoInternals.defaultRemoteCollectionDriver().mongo;
const session = client.startSession();

I don’t have a complete example at the moment but you could check out this test case, which updates two documents atomically using the transaction APIs.


Quick question, on the test example you posted the updates are done using rawCollection, so right now that is the only way to work with transactions? meaning they wont work using meteor/mongo?


Thats right, for now rawCollection is the way to work with transactions.