ARTICLE AD BOX
i just started a project in which chat system which plays an important role in the system the probem is scaling i am planning a mysql and mongodb in which mysql stores the others data and monogoose is only for chat system the probem i am currently facing is i am storing everything in one collection like everyperson chat in one collection the probem i came up with with an issue of horizontal scaling [ what if the chat gets on and with the millions of data's in the in one collection ], this is my current model
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import mongoose, { HydratedDocument } from 'mongoose'; import { Attachment } from './types/attachments.types'; import { CallEvent } from './types/callevents.types'; import { ReadReceipt } from './types/readReceiptp.types'; export type ConversationDocument = HydratedDocument<Conversation>; @Schema() export class Conversation { @Prop({ required: true }) senderID!: string; @Prop({ required: true }) senderName!: string; @Prop({ required: true }) receiverID!: string; @Prop({ required: true }) message!: string; @Prop({ required: true }) attachments!: Attachment[]; @Prop({ required: true }) callEvents!: CallEvent[]; @Prop({ required: true }) readReceipts!: ReadReceipt[]; @Prop({ required: false }) replyTo!: String; @Prop({ required: true, default: false }) readReceipt!: ReadReceipt; @Prop({ required: true }) timestamp!: Date; } export const ConversationSchema = SchemaFactory.createForClass(Conversation);any other way for suggestions then please do let me know
