开发者社区> 问答> 正文

mongoose如何保证填充的数据是唯一的

const UserSchema = new Schema(
  {
    userId: String,
    userName: String,
    password: String,
    friendList: [
      {type: Schema.Types.ObjectId, ref: 'User'}
    ],
  },
  {
    timestamps: true
  }
)

请问如何能保证friendList数组内的用户是唯一的呢

展开
收起
xiawang1024 2021-10-14 17:09:20 11890 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
事务、全局索引、透明分布式 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载