optimistic-lock-error.js 803 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const BaseError = require('./base-error');
  3. /**
  4. * Thrown when attempting to update a stale model instance
  5. */
  6. class OptimisticLockError extends BaseError {
  7. constructor(options) {
  8. options = options || {};
  9. options.message = options.message || `Attempting to update a stale model instance: ${options.modelName}`;
  10. super(options.message);
  11. this.name = 'SequelizeOptimisticLockError';
  12. /**
  13. * The name of the model on which the update was attempted
  14. *
  15. * @type {string}
  16. */
  17. this.modelName = options.modelName;
  18. /**
  19. * The values of the attempted update
  20. *
  21. * @type {object}
  22. */
  23. this.values = options.values;
  24. /**
  25. *
  26. * @type {object}
  27. */
  28. this.where = options.where;
  29. }
  30. }
  31. module.exports = OptimisticLockError;