Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const session = await mongoose.startSession();
- session.startTransaction();
- const opts = { session, new: true };
- tableModel = MYMODEL.(data);
- tableModel.save(async function(err, response) {
- if (err) return handleError(err, res);
- else {
- try {
- console.log('Mongo success');
- await session.abortTransaction();
- session.endSession();
- console.log("rolled back")
- }
- catch(e) {
- next(e)
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement