'Best schema design for Journal app storing notes as array or just object?
I am building a Journal app for practice. Journal of a user contains many notes. Right now, I am creating a journal object for every user and storing notes as an array. Is this the right approach or should I just create a Note object for every note? The reason I created an object for all notes is that most of the time app loads all notes, so I thought this will be a good approach but I am facing some difficulties now(for eg. implementing search in notes, I cannot search for notes using MongoDB Atlas Search cause it returns the entire object i.e Journal if it matches a query.) Which is the right schema design for such an app? And where do I learn how to design schemas? My current Schema design is:
{
userid: {
type: String,
required: true,
},
notes: [
{
content: {
type: String,
},
Date: {
type: Date,
default: Date.now,
},
},
],
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
