I have this document in my MongoDB
{
    _id: 603e59811a640a0d1097bc35,
    firstName: 'ABC',
    lastName: 'XYZ',
    address: 'Mars',
    age: 20,
    mobile: 9922334455,
    email: 'abc@gmail.com',
    password: 'pass',
    type: 'citizen',
    __v: 0
}
And below is the code I am using to fetch it:
router.post('/login', (req, res) => {
    const user = new User({
        userName: req.body.userName,
        password: req.body.password,
    })
    User.findOne(
        {
            email: user.userName,
            password: user.password,
        },
        (err, data) => {
            console.log(data)
        }
    )
})
In console I am getting output as:
{
  _id: 603e59811a640a0d1097bc35,
  firstName: 'ABC',
  lastName: 'XYZ',
  address: 'Mars',
  age: 20,
  mobile: 9922334455,
  email: 'abc@gmail.com',
  password: 'pass',
  type: 'citizen',
  __v: 0
}
Now, when I am trying to access the data like console.log(data.firstName) its showing me as undefined. But if I do console.log(data._id) which is the first propertie's key, its giving the correct value which is 603e59811a640a0d1097bc35
Update
I tried debugging and found this: enter image description here
The datatype of result is model. And if I use ${result._doc.firstName} its giving me the first name. But is this the correct way of accessing the properties?
 
    