Jan 19, 2023
0
Level 2
Nested doc in MongoDb
hi all, is it best to use mongo db in the following way. i have data that can be as follows:
//message
{
id: string,
conversation_id: string,
type: 'image' | 'document' | 'text' | 'buttonReply',
text: string,
data: object,
reply_msg_id: string,
}
the data object can have a different structure depending on the type field
this can grow depending on the type field in message
//data obj
{
media_link: string,
button_reply: {
id: string,
title: string
}
}
is it ok to save as nested doc in mongo or to create referencing models?
Please or to participate in this conversation.