0
私はモンゴデータベースの「ユーザー」および「通知」のコレクションを持って、私はそうのようなIDを使用してそれらを関連付ける必要があります。mongoose関連のドキュメントでrefをいつ使うべきですか?
const NotificationSchema = new mongoose.Schema({
type: {
type: String,
required: true
},
userId: {
type: Schema.Types.ObjectId,
required: true
}
});
またはREF使用:必要
userId: {
type: Schema.Types.ObjectId,
ref: 'User'
}