聊天系统的mongodb设计问题
天蓬老师
天蓬老师 2017-04-24 09:12:18
0
4
634

我想用mongodb加nodejs做一个聊天系统 他有添加好友和给好友分组的功能 不知道这样的mongodb要怎么设计比较好

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
黄舟
{
    _id:,
    nick:'',
    account:'',
    password:'',
    friends:[
        {grounp:'分组1',list:[用户ID1,用户ID2]},
        {grounp:'分组2',list:[用户ID3,用户ID4]}
    ]
}

People clearly asked about mongo, but everyone above answered redis. Redis has the same uses as redis. It is very useful for one-dimensional linear data. However, for data similar to relational data, mongo must be used.

洪涛

Database: mongodb is still not fast enough, after all, considering persistence. It is recommended that you add a layer of cache, and using redis' ordered collection would be a good choice.
Programmatically, it is implemented through websocket, so that web/iOS/Android can communicate. After the client and server establish a connection, the client sends the message to the server and saves it in redis, and then sends it to the online target friends through the server.
If the other party is offline, cache it in redis. As soon as the other party comes online, the unread messages will be retrieved and sent to the other party

Peter_Zhu

redis takes the lead and pgsql is the backup. mongodb does this. . . . . It’s still not quite suitable for this scene.

左手右手慢动作

No persistent database will satisfy you in terms of this requirement. You need redis for buffering, or you can even ask redis for persistence (you can search online for specific solutions. I remember Momo’s technical staff did it Overshare)
As for how to store data in mongodb after buffering, it is much easier. You basically only need to consider how to store the data in a reasonable way

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!