You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Re: #6087, now that we have an option to explicitly allow changing the discriminator key, we should disallow setting the discriminator key in updateOne(), etc. unless that option is set.
The text was updated successfully, but these errors were encountered:
constassert=require('assert');constmongoose=require('mongoose');mongoose.set('debug',true);mongoose.set('useFindAndModify',false);const{ Schema }=mongoose;run().catch(err=>console.log(err));asyncfunctionrun(){awaitmongoose.connect('mongodb://localhost:27017/test',{useNewUrlParser: true,useUnifiedTopology: true});awaitmongoose.connection.dropDatabase();constbaseSchema=newSchema({},{discriminatorKey: 'type'});constbaseModel=mongoose.model('thing',baseSchema);constaSchema=newSchema({aThing: {type: Number},},{_id: false,id: false},);constaModel=baseModel.discriminator('A',aSchema);constbSchema=newSchema({bThing: {type: String},},{_id: false,id: false},);constbModel=baseModel.discriminator('B',bSchema);// Model is created as a type Aconstdoc=awaitbaseModel.create({type: 'A',aThing: 1});constres=awaitbaseModel.findByIdAndUpdate(doc._id,{type: 'A',bThing: 'one',aThing: '2'},{runValidators: true,/*overwriteDiscriminatorKey: true*/},);assert.equal(res.type,'B');}
Re: #6087, now that we have an option to explicitly allow changing the discriminator key, we should disallow setting the discriminator key in
updateOne()
, etc. unless that option is set.The text was updated successfully, but these errors were encountered: