[英]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:他们的问题太多了,我无法回答:
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.