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.
Oh. Now i wrote:
const womanData = await User.findOne({_id: womanid}).select('_id name age photos')
and it works...