Skip to content

Optimistic concurrency: select subset of fields to apply optimistic concurrency to #10591

Closed
@vkarpov15

Description

@vkarpov15

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

The Schema optimisticConcurrency option is currently a boolean: optimistic concurrency is either on for the whole document, or off for the entire document. Would be nice to allow specifying either fields to enable optimistic concurrency:

const opts = { optimisticConcurrency: ['status'] };

new Schema({
  name: String,
  age: Number,
  status: { type: String, enum: ['PENDING', 'APPROVED', 'REJECTED' ] }
}, opts);

Or fields to exclude from optimistic concurrency:

const opts = { optimisticConcurrency: { exclude: ['name'] } };

new Schema({
  name: String,
  age: Number,
  status: { type: String, enum: ['PENDING', 'APPROVED', 'REJECTED' ] }
}, opts);

See #10583

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions