I know that if the size of the document grows, it will have a bad influence on Mongolia. So I avoid the following embedding document method.
However, many of the bulletin board basic examples use the following code.
var boardSchema = mongoose.Schema({
writer: String,
password: String,
title: String,
contents: String,
comments: [{
name: String,
memo: String,
date: {type: Date, default: Date.now}
}],
count: {type:Number, default: 0},
date: {type: Date, default: Date.now},
updated: [{contents: String, date:{type: Date, default: Date.now}}],
deleted: {type: Boolean, default: false}
});
In the case of bulletin boards and comments, is it possible to simply implement the embedded document method? Or did I misunderstand?
In addition, I implemented bulletin boards and comments in the following way.
var boardSchema = mongoose.Schema({
...
comments: [{type: ObjectId}],
...
});
var commentSchema = mongoose.Schema({
name: String,
memo: String,
date: Date
});
When creating in the comment schema, I implemented it by pushing the objectId as the bulletin board schema.