Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
Please help me implement the logic code for depositing and withdrawing in node.js and mongodb

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda