Hello All,
We want to build a simple chat feature in our application.
we thought of a model like this,
{
postId: 'link to post where we have users details',
messages: [
{
from: 'userId',
to: 'userId',
sentAt: new Date()
},
{
from: 'userId',
to: 'userId',
sentAt: new Date()
},
{
from: 'userId',
to: 'userId',
sentAt: new Date()
},
.
.
.
]
}
and we will subscibe to the collection on client side based on postId
if there is any new messages we will push it to messages
property.
Our worry here is,
as meteor can only identify the changes on root properties, whenever we insert a new message we worried that meteor will send back all the messages object again to client side.
So we’re wasting bandwidth.
Can somebody confirm that meteor can only observe changes on root properties.
because of the above issue we thought of some other model, which is simply saving each message as new record
{ from: 'userId',to: 'userId',postId:'',sentAt: new Date(), msg: '' }
{ from: 'userId',to: 'userId',postId:'',sentAt: new Date(), msg: '' }
{ from: 'userId',to: 'userId',postId:'',sentAt: new Date(), msg: '' }
{ from: 'userId',to: 'userId',postId:'',sentAt: new Date(), msg: '' }
but we worry that there will be too many number of records we’re saving in collection.
We know lot of meteor developers have developed chat application before, we just want to know their thoughts on this and what worked very well for them.
Thanks