我想用mongodb加nodejs做一个聊天系统 他有添加好友和给好友分组的功能 不知道这样的mongodb要怎么设计比较好
黄舟2017-04-24 09:14:18
{
_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.
PHP中文网2017-04-24 09:14:18
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
天蓬老师2017-04-24 09:14:18
redis takes the lead and pgsql is the backup. mongodb does this. . . . . It’s still not quite suitable for this scene.
ringa_lee2017-04-24 09:14:18
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