In my meteor app, I want to create a separate set of collections for every user when they register. The names of the collections will depend on the user id. For example, if a user with id xyz logs in, then I'd like to create some collections like xyz_collection1 , xyz_collection2 and so on..These collections are created when the user first registers. And on creation, these should be published by the server and subscribed to by the client. An example scenario: Each user has a set of bills scheduled for next month. When the user logs in, I want to show only his bills that are scheduled for next month. There can be two approaches:
- I can have one collection named "NextMonthBills" which contains the bills for all the users that are due for next month. Then when a particular user logs in, I fetch from this collection only those bills belonging to him. (this is easier to implement)
- I can have separate "NextMonthBills" collections for each user; of the form "user1_NextMonthBills", "user2_NextMonthBills" and so on. Then when a user logs in, I fetch all the data from the collection belonging to that user id.
Question 1:
I chose the 2nd one. Does it make sense data-security-wise?
Question 2
On the client side, I can get the user id easily. How do I send this to the server , so it can publish the relevant collections? How do I get the server publish to run only when the user registers. ? Is this possible?