mongoose-transactions
mongoose-transactions copied to clipboard
transaction.insert('Order', oder) does return order id but does not save on DB
I want to save the order to MongoDB (cloud-hosted ). However, if I use transaction.insert('Order', order) to save data, it does return the ID of the saved object but does not save on DB. ` async function start() { try { const orderId = transaction.insert("Order", order);
res.status(200).json({
sucess: true,
data: orderId,
});
} catch (error) {
console.error(error);
const rollbackObj = await transaction.rollback().catch(console.error);
transaction.clean();
}
}
start(); `
Have you solved it?I also cannot save into DB. When transaction,run(), will always be loaded.Can't get to the next step