如何解决NodeJS Mongoose数据结构设计,将多个Todo项目引用到具有类别的项目中
我正在使用reactjs并将mongodb / mongoose用作数据库。我有一个项目模型和类别模型,想知道如果我想有多个待办事项并将其分类为每个项目,这是否是建立关系的正确方法?
项目模型:
const projectSchema = new mongoose.Schema(
{
user: {
type: mongoose.Schema.Types.ObjectId,ref: "user",},items: [
{
categoires: {
type: mongoose.Schema.Types.ObjectId,ref: 'categories'
},name: { type: String },description: { type: String },],}
);
类别模型
const categorySchema = new Schema(
{
project: {
type: mongoose.Schema.Types.ObjectId,ref: "project",name: { type: String,required: true },}
);
我的架构引用正确吗?我是否应该将items数组分成另一个模型,然后尝试将这些项目引用到项目模型中?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)