Multi-document Atomicity in Mongoose (MongoDB)
A short example to show how to use MongoDB's v4.x multi-document transactions in mongoose
.
This was adopted from the official MongoDB example here but instead of the native mongo client we use mongoose
.
Setup
Follow the instructions in the "Set Up" section here. Then in your shell:
yarn
DB_URI='your_mongo_atlas_uri' node init
DB_URI='your_mongo_atlas_uri' node transactions