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

199
Views
Converting Timestamp to Cursor

I am using prisma schema with mongodb and what I am doing is having a date be generated like so:

model Book {
  id        String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  title     String
  author    Author   @relation(fields: [authorId], references: [id])
  authorId  String   @db.ObjectId
  createdAt DateTime @default(now())
}

node.createdAt is showing: 2021-11-29T12:38:22.248Z

So the tricky thing is a have two functions, one takes in a node from a list of edges and gets the createdAt property on the node the other converts the cursor back.

To convert the createdAt property I did this: Buffer.from((node.createdAt).getTime().toString()).toString('base64') which gives me: MTYzODE4OTUwMjI0OA==

Now to convert it back I have a function that takes in a cursor which I handled like this: return new Date(parseInt(Buffer.from(cursor, 'base64').toString())) this returns the same thing back: 2021-11-29T12:38:22.248Z

This is not working however and I think it's because the new Date returns a new instance. I'm having some real trouble getting this one to work

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!