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

120
Views
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 answers
Answer question

0

Fixed:

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