MCPcopy
hub / github.com/sequelize/sequelize / isSoftDeleted

Method isSoftDeleted

src/model.js:4410–4421  ·  view source on GitHub ↗

* Helper method to determine if a instance is "soft deleted". This is * particularly useful if the implementer renamed the `deletedAt` attribute * to something different. This method requires `paranoid` to be enabled. * * @returns {boolean}

()

Source from the content-addressed store, hash-verified

4408 * @returns {boolean}
4409 */
4410 isSoftDeleted() {
4411 if (!this.constructor._timestampAttributes.deletedAt) {
4412 throw new Error('Model is not paranoid');
4413 }
4414
4415 const deletedAtAttribute = this.constructor.rawAttributes[this.constructor._timestampAttributes.deletedAt];
4416 const defaultValue = Object.prototype.hasOwnProperty.call(deletedAtAttribute, 'defaultValue') ? deletedAtAttribute.defaultValue : null;
4417 const deletedAt = this.get(this.constructor._timestampAttributes.deletedAt) || null;
4418 const isSet = deletedAt !== defaultValue;
4419
4420 return isSet;
4421 }
4422
4423 /**
4424 * Restore the row corresponding to this instance. Only available for paranoid models.

Callers 3

instance.test.jsFile · 0.80
User.tsFile · 0.80

Calls 1

getMethod · 0.95

Tested by

no test coverage detected