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

125
Vistas
Mongoose `findById` not returning expected document

When I find a document using the following line:

const user = await User.findById(req.user.id).populate('input')

And then I console.log user, I can see the document that fulfills the query.

However, when I add .updateOne({ formResponded: '1' }); to the previous line like so:

  const user = await User.findById(req.user.id).populate('input').updateOne({ formResponded: '1'});

and I console.log user I do not get any record but instead an object that looks like this:

{ n: 1,
  nModified: 1,
  opTime: {
    ts: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1635212112 },
    t: 41
 },
 electionId: 7fffffff0000000000000029,
 ok: 1,
 '$clusterTime': {
   clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1635212112 },
   signature: { hash: [Binary], keyId: [Long] }
 },
 operationTime: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1635212112 }
} 

Why does this happen?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Fixed:

   const user = await User.findByIdAndUpdate({ _id: req.user.id }, { formResponded: '1' }).populate('input')
about 4 years ago · Juan Pablo Isaza Denunciar
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