am creating the logic that allows user to deposit money and withdraw money in node.js with mongodb. But I try my little knowledge to make it works, and I can't seems to bring the logic correctly. below is my code that I'm trying to deposit please help me as mynknowledge seems insufficient curently.
Below is code:
import User from "../models/user.js"
export const depositSlip = async (req, res) => {
const { accountNo, name, amount } = req.body;
try {
const deposit = await User.findOne({ accountNo, name });
if(!accountNo === name ) {
return res.status(404).json({ message: "Account details does not match" })
} else {
deposit
}
if (!deposit) return res.status(404).json({ message: "Account Number does not exsit" })
await deposit.save({ amount })
} catch (err) {
}
}
please I don't even know if I'm creating the logic right but please take it as if you are teaching some one a new and guide me through.
And as for the withdrawal code, I don't even implement it because I haven't finished the depositing cod first. please come to my rescue, I know am asking a a lot from you of your time, but this is really important for me to create this. So, please help Thank you.