Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda