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

201
Vistas
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
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