const payment = await paymentsSchema.findOne({ student: s_id, guardian: g_id }, {},
{ sort: { 'createdAt': -1 } })
console.log(payment)
payment.balance = (payment.balance + settings.overtime_rate)
// Create a new document with the updated values
const updatedPayment = paymentsSchema(payment.toObject());
// Save the new document to the database
updatedPayment.save((err) => {
if (err) throw err;
console.log('Payment updated successfully');
});
I expect to have 2 documents after posting this update, the original and the updated document...