I am creating a meteor app that will be intended for mobile. I was wondering if there is a limit to the number of mongo collections a meteor app could have.
I would like to make a new collection (or a few new collections) automatically for every user account that signs up through my app. If all goes well there would likely only be no more than a couple thousand users.
Is doing something like this possible to make and have the collection(s) automatically create when a user signs? If so, how would I go about doing this? I assumed i could just pass a variable (likely related to the users id number) into the collection name?
I believe each collection you create incurs some overhead.
Have you considered storing all over your user’s documents in the same collection, and then place a
userId property on each document, so you know who owns what? Access controls can be used to further limit who can access which documents.
Sounds like an XY problem, why do you want to do that exactly?
Thank you for the quick replies. I have thought about storing everything in one collection. But also figured that might be more confusing. In addition, I figured it would take more time to search large collections.
Example of my situation: I am looking to make a messaging app where people can have 1-on-1 conversations or group conversations. i was each user in the conversations to have their own copy of everybody’s messages in their conversations. That way if a member in a conversation they are in delete’s a message, it only deletes for themselves, but other users can still see it. With that being said, i can either store all messages in one giant collection and make duplicate messages with different id numbers for each message, OR, i can have a different messages collection for each user.
I thought have a collection for each user would compile and search more quickly given my attached example…but you see how it could scale quickly.
With that being said, what are your thoughts on this or how could I go about making a collections for every user account?
why not just insert a new document for each one on one conversation, and insert some data to signify that a message was deleted? Eg:
users: ["1", "2"],
text: "Hello, is anybody here?",
Sorry. No meteor expert here but some rough knowledge of it.
Can i insert unlimited messages into a single message variable within a single document? if so, how do i do that?
Create an array or a relation