我正在使用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)