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

69
Views
Mongodb send me incorrect object with different id

I use express as backend, mongodb and mongoose. I don't understand why i get from database incorrect object.

In general, i send from frontend post request with id: 6210915b2b72a91fe72d9201. On backend i reseive that id and want to fetch object with same id from mongodb

This code:

router.post('/reaction_on_user', async (req, res) => {


  let womanid = req.body.id 
  console.log(womanid, ' before findOne')
  const womanData = await User.findOne({womanid}).select('_id name age photos')
  console.log(womanid, ' after findOne')

In console.log i see id which i send -- 6210915b2b72a91fe72d9201. But object from database have different id -- 6210915b2b72a91fe72d91f5. This different id was some requests ago.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Oh. Now i wrote:

const womanData = await User.findOne({_id: womanid}).select('_id name age photos')

and it works...

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!