I wanted to enquire as to how to partion my chat data into realms in mongoDB realm. Users can be part of of any number of chatrooms.
Right now my chat database has _partition as the partitionValue, and the following collections-
export const chatroomSchema = {
name: 'chatroom',
properties: {
_id: 'objectId',
_partition: 'string?',
date: 'date',
last_message: 'string',
title: 'string',
},
primaryKey: '_id',
};
export const userSchema = {
name: 'user',
properties: {
_id: 'objectId',
_partition: 'string?',
chatrooms: 'chatroom[]',
friends: 'user[]',
name: 'string',
photoUrl: 'string',
username: 'string',
},
primaryKey: '_id',
};
export const messageSchema = {
name: 'message',
properties: {
_id: 'objectId',
_partition: 'string?',
content: 'string',
chatroom_id: 'string',
date: 'date',
sender: 'user?',
},
primaryKey: '_id',
};
export const memberSchema = {
name: 'member',
properties: {
_id: 'objectId?',
_partition: 'string?',
chatroom_id: 'string?',
participants: 'user[]',
},
primaryKey: '_id',
};
Thank You In Advance. Stay Safe!