Reputation: 55
I am creating a chat application in Ruby on Rails and am trying to store messages in an array using Mongodb and mongoid. I have a model called Chat and it contains an array field called chatlog. Is there a better way to store chat history in Mongodb using rails?
Upvotes: 0
Views: 619
Reputation: 936
it will be better to create a chat/message table and store messages in that table. you can take benefits of mongodb sharding and scaling by doing that.
class User
include Mongoid::Document
field :name
end
class Message
include Mongoid::Document
field :body
referenced_in :user
end
see the link below to see how mongodb helps you support high volume data.
your models can be like following:
http://docs.mongodb.org/manual/sharding/
Upvotes: 1