Closed AhmedLebda closed 1 month ago
The user returned after db query await user.findOne({username} shouldn't return _id because we used the json method on user schema to return id instead of _id, so all lines that used user._id are updated to user.id
await user.findOne({username}
_id
id
user._id
user.id
await user.findOne({username} returns a query object which in fact contains _id it will only return id if we invoked the .toJSON() method on it
sorry for my mistake.
The user returned after db query
await user.findOne({username}
shouldn't return_id
because we used the json method on user schema to returnid
instead of_id
, so all lines that useduser._id
are updated touser.id