Answer the question
In order to leave comments, you need to log in
How to register multiple users?
It is necessary to make an application (nodejs, mongodb) that supports registration of multiple users. How to create a user, models, perform authorization, check cookies, etc. - that's all I know. Those. I can create a user or several, but each such user, relatively speaking, will have access to the entire database. The catch is precisely in creating many users with the same mongodb collection names, but different documents in them (each user has his own documents).
For example, an application for organizing a library. The database has collections - authors, genres, publishers, books, etc. User_1 registers, logs in and creates his own records of books, authors, genres... And they are available only to him. User_2 is registered - and everything is the same.
It, in general, a question of designing a DB. How should it look?
Is there a separate database for each user?
Or is there only one database, but inside it is somehow divided by users?
Or is there only one database, and everything is in a heap, and the connections of users and their collections are made through Schema.Types.ObjectId?
What can you read, watch to understand how to do such things?
I suspect that for such things it would be better to use something sql-shaped, but nevertheless, I want to understand how to solve the problem in the context of a document-oriented database.
Unless (I quite admit that I'm trying to do nonsense) such things are generally extremely stupid to do on mongodb, regardless of the degree of complexity of the application itself. If so, if possible, explain why it is stupid.
Answer the question
In order to leave comments, you need to log in
For example, an application for organizing a library. The database has collections - authors, genres, publishers, books, etc. User_1 registers, logs in and creates his own records of books, authors, genres... And they are available only to him. User_2 is registered - and everything is the same.
Every author, book, etc. assign the userId of its owner. Then you just get the necessary data on this id for a specific user.
Or there is only one database, and there everything is in a heap, and the connections of users and their collections are made through Schema.Types.ObjectId
Yes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question