Hi,
I am getting error "Current topology does not support session" Plese refer attached image..
and code as
async function insertBooking(parking, aFunction) {
const session = await BookingSchema.startSession().catch(error => {
console.log(error);
});
try {
session.startTransaction();
let booking = new BookingSchema(parking)
mongoose.startSession();
booking.save(function (err, booking) {
if (booking) {
//code to be run
}
})
await session.commitTransaction().catch(error => {
console.log(error);
});
session.endSession()
} catch (error) {
await session.abortTransaction().catch(error => {
console.log(error);
});
session.endSession();
throw error;
}
}
Above code completely work on local system. but erro occure on cloud server (Digital ocean) Please let me know if another information needed.
It seems you haven't installed MongoDB 4.0
on your cloud server which supports transactions.
Transaction works only with >= MongoDB v4.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With