首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >猫鼬添加更多键: ref字段中的值

猫鼬添加更多键: ref字段中的值
EN

Stack Overflow用户
提问于 2020-08-03 23:13:01
回答 1查看 42关注 0票数 0
代码语言:javascript
复制
   organs: [
    {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Organ',
      healthValue: { // i want to add this field but it is becoming invalid, not generating auto with default val
        type: Number,
        default: 0,
      }
    },
  ],

我有一个用户模式,并且在这个模式中还有器官键。我用推荐的方法保存器官属于用户器官。我也应该保持器官健康的价值,但我不能把它放在像上面这样的参考领域。我该怎么做?我不能添加更多键:值来填充(type & ref)字段吗?

EN

回答 1

Stack Overflow用户

发布于 2020-08-03 23:34:17

代码语言:javascript
复制
   organs: [
    {
      organId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Organ',
      },
      healthValue: {
        type: Number,
        default: 0,
      },
      isOwned: {
        type: Boolean,
        default: false,
      },
    },
  ],

我想我解决了上面的代码块,我确实使用了错误的语法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63238150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档