With mongo is preferable to handle large collection of small document instead of small collection of big documents.
You should change your chat model which must look like this for the moment:
// chat model
{
_id: ObjectId("/..."),
title: "...",
messages: [
{_id: 1, text: "...."},
{_id: 2, text: "...."},
....
]
}
To something like this:
// chat model
{
_id: ObjectId("/..."),
title: "..."
}
With a collection of messages references the chat model
// messages collections
{
_id: ObjectId("...."),
chat_id: "...",
text: "..."
},
{
_id: ObjectId("...."),
chat_id: "...",
text: "...
},
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…