小编Yog*_*wal的帖子

findOneAndUpdate不更新判别器

我正在使用Node,Express和Mongoose开发REST API.当我更新基本模型时,一切都很完美.但是当我尝试sportEvent在这种情况下更新鉴别器对象时,它不起作用.

Event.js - 事件数据模型具有所有集合通用的基本模式,并具有用于该集合的其他详细信息的鉴别器.

// base schema for all the events
// includes basic detail for all the events
const eventSchema = new Schema({
  //title for the event
  title: {
    type: String,
    required: true
  },

  //description for the events 
  description: {
    type: String,
    required: true
  },

  //event type for the event. such as Music, Sports, Expo, Leisure
  eventType: {
    type: String,
    required: true,
  }
}, { discriminatorKey: 'eventType' });

//sport event model for extending the basic event …
Run Code Online (Sandbox Code Playgroud)

javascript mongoose mongodb node.js express

11
推荐指数
1
解决办法
605
查看次数

标签 统计

express ×1

javascript ×1

mongodb ×1

mongoose ×1

node.js ×1