Creating users in MongoDB Atlas using Node.js

I ran into this problem and solved it.
first answer is the user created?
if yes, then look for the problem in the connection code. I can tell you something after analyzing your code for connecting with MongoDB.
Not the code for creating the User, but the code for creating the connection.

Were you really able to create an Atlas database user with the node-js driver?

this is how the user entry looks like in MongoDB Compass

{"_id":{"$oid":“60afb2309bec572f1486d455”},“email":"test4@gmail.com”,“password”:"$2a$10$iqPN8mgnvEHkRmZXa.tEW.fVuUEsN.m8OPC6eSX0HgiHoMNAdIZMW","__v":0}

this is how the user entry looks like in MongoDB Compass:

While your collection is named users, this is not a user that can access an Atlas database. It might give access to an application that has access to Atlas, but that user cannot access Atlas directly.

See Node.js cant create user in MongoDB Atlas

I mean the user in the database created by the application. I saw a construct in the question: “… creating a user in MongoDB Atlas”. if it was written: “… database user”, I would not write my answer.