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

146
Vistas
repeat events on certain dates node.js

I have a function in which stores the current date, and time (timestamp) in mysql db.

formatted like so:

'2022-01-28 13:00:00.000000'

The way this gets inserted into my table is like so:

    var insertNewEvent = "INSERT INTO SCHEDULE (DATE,LOCATION,ASSIGNED_TRAINER,CLIENT_USERNAME,ENDDATE, ID, EVENT_NAME, SESSION_STATUS) VALUES('" + eventDetails.eventDate + " " + eventDetails.eventStartTime + "', '" + eventDetails.eventLocation + "', '" + eventDetails.trainerUserName + "', '" + eventDetails.selectedClient + "', '" + eventDetails.eventDate + " " + eventDetails.eventEndTime + "', '" + uniqueID + "', '" + eventDetails.nameOfEvent + "', '" + session_status + "')"

and yes, I am changing this query as I know it is unsafe and not right.

but now what I want is for example, I want to say insert the same event (all same event details), but have it repeat on the day i inserted it for, and then every let's say monday, wednesday, friday after that. I am a little but stumped on how to go about this, I was hoping someone could guide me. thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try creating a middleware to handle it, for example:

var checkDate= Date.UTC(new Date().getFullYear(), new Date().getMonth(),
              (new Date().getDate() + 1));
const myMiddleware= async(req, res, next) =>{
    if(Date.now()>= checkDate){
        checkDate= Date.UTC(new Date().getFullYear(), new Date().getMonth(),
                   (new Date().getDate() + 1));
        // your code here
        
    }
    next();
}

then use it

app.use(myMiddleware);
about 4 years ago · Juan Pablo Isaza Denunciar
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