简体   繁体   中英

Node Express Backend. How to manage mongodb connections? Mongodb users or collection of users?

I am developing a frontend with ANGULAR and backend with Node and Express. Is a simple backend for internal use in my company with a small quantity of users: 15-20. The backend connects to Mongodb. The mongo server is started with authentication and I can create users with built-in roles in mongo: read, write, etc. But all the examples I found in tutorials usually creates a collection of users instead of using the mongodb built-in users. As far I know, if use built-in mongo users I need to start a new connection for each user because the user and password is part of the Connection String URI

I have some doubts:

  1. Is it a bad idea to use built-in users?
  2. If I use built-in users. How to manage the logout of the user? I don't find examples.

"Users" in this context is usually connections to the database.

Lets say you have a database with data serving several applications. One which only has access to read the data, and another to write and update. You can make sure the read only app, wont write with 2 users of the database. Typically, you'll also have an admin user that has global all access for administrators.

When your coworkers wish to update some data through the second application. The application will authenticate to the database and write on their behalf. Whether or not someone has access to use the application to update data is not something the database should decide.

I hope this helps to understand the context of "user"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM