Skip to content

[Bug] optimisticConcurrency nested paths #16054

@AbdelrahmanHafez

Description

@AbdelrahmanHafez

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

optimisticConcurrency option needs to handle nested paths properly, it currently doesn't.
Should handle both directions: profile means optimisticConcurrency is triggered by profile.name, and profile.address.country should be triggered by setting profile.address.

const profileSchema = new Schema({ firstName: String, lastName: String }, { _id: false });
const userSchema = new Schema({
  profile: profileSchema,
  balance: Number
}, { optimisticConcurrency: { exclude: ['profile'] } });

const User = mongoose.model('User', userSchema);
const user = await User.create({ profile: { firstName: 'Alice', lastName: 'Smith' }, balance: 100 });

user.profile.firstName = 'Bob';
user.$__delta();

// BUG: user.$__.version === VERSION_ALL (3)
// EXPECTED: user.$__.version === undefined (profile is excluded, so profile.firstName should be too)

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions