jagi / meteor-astronomy

Model layer for Meteor
https://atmospherejs.com/jagi/astronomy
MIT License
604 stars 67 forks source link

[Feature request] Mongo transactions #706

Closed boomfly closed 2 years ago

boomfly commented 5 years ago

We need to modify .save method to accept session option to it. Collection.save({session}) I use this helper function for handling transactions:

storeWithSession = (doc, session) ->
  collection = doc.constructor.getCollection().rawCollection()
  if doc._isNew
    await collection.insertOne {
      ...doc.raw()
      _id: Random.id()
    }, {session}
  else
    await collection.updateOne {_id: doc._id}, doc.getModifier(), {session}
IrvingGuerra commented 2 years ago

@lukejagodzinski

lukejagodzinski commented 2 years ago

I'm not developing this library anymore. I only do bug fixes.