更新nodejs中嵌套对象的值

问题描述

const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const instructorSchema = new Schema(
  {
    instructorID: {
      type: String,required: true,unique: true,trim: true,minlength: 3,},name: { type: String,required: true },dob: { type: Date,gender: { type: String,address: { type: String,phone: { type: Number,email: { type: String,password: { type: String,userRequests: [
      {
        userProfile: { type: String },userName: { type: String },weight: { type: String },height: { type: String },gender: { type: String },requirement: { type: String },assigned: { type: String },],{
    timestamps: true,//it will automatically create fields when it is created or modified
  }
);

const Instructor = mongoose.model("Instructor",instructorSchema);

module.exports = Instructor;

我想为给定的userProfile(这是一个obejectID)和给定的教师(instructorID)更新需求属性的值。有人可以帮我解决nodejs路由。

我在stackoverflow上进行了检查,但没有找到答案。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)