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

294
Visualizações
Graphql Date of the event is passed, how to update automaticly is Completed?

I have no idea how to phrase this question and to be honest, when I think about it, this should have a really simple answer but for some reason, I couldn't find the best way to do it.

I'm building a React Native app with a Prisma backend. I don't want to involve the front end at all to solve this. I have a session model that has a date of the event and isCompleted param. I would like to be able to update isCompleted when the date of the event is in the past automatically. Backend is running on Heroku server, without setting up a cron job or something else, is this possible to do?

here is the model and update code I have, but not sure where to tie this to make sure it always updates all the sessions based on the time.

export const SessionUpdate = {
updateSessionCompletion: async (parent, args, context): Promise<any> => {
    try {
      const session = await prisma.session.findUnique({
        where: {
          id: args.id,
        },
      });
      if (session && session.date < new Date()) {
        console.log(session.date, new Date());

        return await prisma.session.update({
          where: {
            id: args.id,
          },
          data: {
            isCompleted: true,
          },
        });
      }
    } catch (error) {
      console.log(error);
    }
  },
}
model Session {
  id             String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  createdAt      DateTime @default(now())
  // updatedAt    DateTime @updatedAt
  isCompleted    Boolean  @default(false)
  title          String
  date           DateTime
  isCanceled     Boolean  @default(false)

}
about 4 years ago · Juan Pablo Isaza
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