【发布时间】:2021-05-24 02:00:16
【问题描述】:
我是 MongoDB 和 Mongoose 的新手,并试图找出处理创建架构的最佳方法。我更习惯于关系数据库,但我希望这将适用于 Mongo。
我正在创建“扩展”其他对象的对象。例如,我有一个人对象,我想将其用作父对象或祖父对象的起点。父母和祖父母都可能具有超出基本人所具有的附加值(我只是在每个中包含一个示例)...
const personSchema = new mongoose.Schema({
name: String,
birthDate: Date,
deathDate: Date,
});
const parentSchema = new mongoose.Schema({
//all the stuff a person has + below:
children: [personSchemas?] //[array of persons, important... parents can also be children,
multiple parents will share the same child]
parentingStyle: String,
})
const grandParentSchema = new mongoose.Schema({
// stuff that a parent has plus
grandparentingStyle: String,
})
【问题讨论】:
标签: node.js mongodb mongoose mongoose-schema