简体   繁体   English

如何使用 MongoDb 在我的 NodeJs 应用程序中为每个组织保留单独的数据库?

[英]How to keep separate database for each organisation in my NodeJs app with MongoDb?

I am building a management application for NGOs based on NodeJs & MongoDB(mongoose ODM).我正在为基于 NodeJs 和 MongoDB(mongoose ODM)的 NGO 构建一个管理应用程序。 I am required to keep a separate DB for each NGO, and when users from a particular NGO login, they will get access to data from their NGO's database automatically.我需要为每个 NGO 保留一个单独的数据库,当来自特定 NGO 的用户登录时,他们将自动访问其 NGO 数据库中的数据。

Applications should able to connect users to their respective databases(NGO) as soon as they log in.应用程序应该能够在用户登录后立即将用户连接到各自的数据库(NGO)。

They are so many questions that I am unable to answer:他们的问题太多了,我无法回答:

  1. Should I first create databases then create users and link them with respective databases?我应该先创建数据库然后创建用户并将它们与各自的数据库链接吗?
  2. How would the application connect users to their DB during login?应用程序在登录期间如何将用户连接到他们的数据库?

I need to know if there's a popular way of handling such a case.我需要知道是否有一种流行的方式来处理这种情况。 I am fairly new to NodeJs, any help and guidance would be greatly appreciated.我对 NodeJs 相当陌生,任何帮助和指导将不胜感激。

Note: It's important for the project to have separate DB for each NGO注意:对于项目来说,为每个 NGO 拥有单独的数据库很重要

MongoDB creates databases as needed automatically, depending on operations performed, so creating databases manually may not be necessary. MongoDB 根据执行的操作,根据需要自动创建数据库,因此可能不需要手动创建数据库。 (Although if you, for example, specifically list databases, then you'd only get back the databases that were used/already created.) (例如,如果您专门列出数据库,那么您只会取回已使用/已经创建的数据库。)

The users themselves, and which databases they are associated with, you'd store in a different database, ensuring that it is absolutely impossible for any of these users to access the user database.用户本身,以及与他们关联的数据库,您将存储在不同的数据库中,确保这些用户中的任何一个都绝对不可能访问用户数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让 MongoDB Atlas 云数据库配合并连接到我的 Nodejs/Express 应用程序? - How can I get the MongoDB Atlas cloud database to cooperate and connect to my Nodejs/Express app? 如何在Node.js / Express.js中将多个请求分开 - How to keep multiple requests separate in Nodejs / Expressjs 如何在Kubernetes中配置Mongodb连接以与我的Node.js应用连接 - How to configure Mongodb connection within kubernetes to connect with my nodejs app 如何将mongodb与Bluemix上的NODEjs应用程序连接? - How can I connect my mongodb with the NODEjs app on Bluemix? NodeJS-让我的应用程序永远运行 - NodeJS - Keep my App running with Forever 如何共享我的本地主机mongodb数据库(适用于我的MERN应用) - How to share my localhost mongodb database (for my MERN app) 如何在Node.js中显示MongoDB数据库中的HTML - How to display html from a mongodb database in nodejs 如何使用 Nodejs 部署 Mongodb 数据库 - How do you deploy a Mongodb database with Nodejs NodeJs 没有在 MongoDb 中创建数据库? 如何解决? - NodeJs is not creating a database in MongoDb? How to solve it? 如何使用 nodejs 显示我的 mongodb atlas 数据库中的所有条目? - How to display all entries from my mongodb atlas database using nodejs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM