0

I am trying to make a chat application in meteorJS and i was thinking of making a seperate collection for each groups dynamically when they initiate chat, I want to publish and subscribe that collection for transmitting chat information and all the group user can subscribe it, but i am not being able to create a collection dynamically.

I tried making a function which gets call when the user subscribe the collection.

this.createDb =(name) ->
  @ChatDb = new Mongo.Collection(name)
  return true

everything is fine, but when i subscribe this collection from client side, ChatDb is unknown, Can any one help me with this, that would be great. :)

ps- i am writing code in angular-meteor framework

Suresh Mainali
  • 232
  • 1
  • 9

1 Answers1

0

Andrew Mao's answer to a similiar question:

In most instances, you probably don't want to create multiple collections, but instead use one collection and send views of it to clients depending on their subscription.

You may want to check out the https://github.com/mizzao/meteor-partitioner package I've built which is designed especially for this purpose, and includes an example for how to do this for multiple chat rooms. You can also see https://github.com/mizzao/CrowdMapper for an implemented example.

I haven't done Meteor for a while now so I couldn't give you a solid answer. But I remember quite clearly that creating collections dynamically is not the recommended way for achieving what you want to do.

Community
  • 1
  • 1
Archy Will He 何魏奇
  • 9,589
  • 4
  • 34
  • 50