Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!