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
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
7.4.0
Node.js version
18.0
MongoDB server version
8.0
Typescript version (if applicable)
5.4.3
Description
When I made an update with arrayFilters in a schema with an embedded discriminators property the method castArrayFilters didn't know the discriminated properties. So Mongoose throws an error "Could not find path "pathDiscriminated" in schema"
Steps to Reproduce
So, You made an update with arrayFilters like the following: model.updateManyWithDeleted( filter, { $set: 'items.$[a].ping': 'test'}, { arrayFilters: ['a.kind': 'one'] }, );
Partial call stack: at _castArrayFilters (../node_modules/mongoose/lib/helpers/update/castArrayFilters.js:100:15) at castArrayFilters (../node_modules/mongoose/lib/helpers/update/castArrayFilters.js:28:3)
Inside method getPath the method schema.path doesn't know the discriminated properties
And the path method doesn't check in the discriminators
Expected Behavior
The castArrayFilters, also check inside discriminators paths
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
7.4.0
Node.js version
18.0
MongoDB server version
8.0
Typescript version (if applicable)
5.4.3
Description
When I made an update with arrayFilters in a schema with an embedded discriminators property the method castArrayFilters didn't know the discriminated properties. So Mongoose throws an error "Could not find path "pathDiscriminated" in schema"
Steps to Reproduce
So, You made an update with arrayFilters like the following:
model.updateManyWithDeleted( filter, { $set: 'items.$[a].ping': 'test'}, { arrayFilters: ['a.kind': 'one'] }, );
And you have a schema like the following
``
const ItemSchema = new Schema({ message: String }, { discriminatorKey: 'kind', _id: false });
const MainSchema = new Schema({ items: [ItemSchema] });
const path = MainSchema.path<MongooseSchema.Types.Array>('items');
const Onechema = new Schema({ping:String});
const TwoSchema = new Schema({pong:String});
path.discriminator('one', Onechema);
path.discriminator('two, TwoSchema);
``
Partial call stack:
at _castArrayFilters (../node_modules/mongoose/lib/helpers/update/castArrayFilters.js:100:15) at castArrayFilters (../node_modules/mongoose/lib/helpers/update/castArrayFilters.js:28:3)
Inside method getPath the method schema.path doesn't know the discriminated properties
And the path method doesn't check in the discriminators
Expected Behavior
The castArrayFilters, also check inside discriminators paths
The text was updated successfully, but these errors were encountered: