I want to create a chat app for 1:1 and group chat activities.
I've created a schema for both scenarios:
{ // group
"id": 1 // id of the group
"name": "Chat Group" // name of group; if there are more than 2 members
"members": [ "member1", "member2", ...] // ids of the group chat members; only they have access to the JSON document
"chatlog": [ "timestamp1": ["member1", "message1"], "timestamp2": ["member2", "message2"], ...] // who sent which message in chronological order
}
Would it be better to store the access list of users in "members" array as seen above or is this solution with "chat_groups"
better:
{ // user
"id": 1 // id of the user
"name": "Max" // name of the user
"chat_groups": [ "1", "2", ...] // ids of the groups, the user is a member of
}