In the code you share the only place we see _id access is in

Since you use user[0] then it must be that user[0] really does not exist. You code is not safe because you use the result of db…find() without testing for a result or not. Many reasons might explain why you do not get user[0].

  1. You are not connected to the appropriate server
  2. You are not using the appropriate database
  3. You are not calling getCollection() with the appropriate collection name
  4. There is no user that matches { “email” : email }
  5. You might need to await when you initialize user with “db…find(…)”
1 Like