我正在考虑一个处理消息应用程序的良好文档结构.
我基本上需要三种(或四种)对象:
我的想法是将联系人嵌入到用户文档中并将消息嵌入到对话文档中:
1.用户
{
username: 'dev.puS',
usernameCanonical: 'dev.pus', // used for unique constraints
email: 'developement.pus@gmail.com,
emailCanonical: 'developement.pus@gmail.com,
salt: 'some hash',
password: 'hash with salt',
logs: { last_login: 12.06.2008, last_password_reset: 04.03.2007 },
state: { online: true, available: false },
contacts: [ user_id1, user_id2, user_id3 ]
}
Run Code Online (Sandbox Code Playgroud)
2.会话
{
members: [ user_id1, user_id2 ],
messages: [
{ author: user_2, body: 'Hi what's up' },
{ author: user_1, body: 'Nothing out here :(' },
{ author: user_2, body: …Run Code Online (Sandbox Code Playgroud)