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

Method isSoftDeleted

lib/model.js:4258–4269  ·  lib/model.js::Model.isSoftDeleted

* 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

4256 * @returns {boolean}
4257 */
4258 isSoftDeleted() {
4259 if (!this.constructor._timestampAttributes.deletedAt) {
4260 throw new Error(class="st">'Model is not paranoid');
4261 }
4262
4263 const deletedAtAttribute = this.constructor.rawAttributes[this.constructor._timestampAttributes.deletedAt];
4264 const defaultValue = Object.prototype.hasOwnProperty.call(deletedAtAttribute, class="st">'defaultValue') ? deletedAtAttribute.defaultValue : null;
4265 const deletedAt = this.get(this.constructor._timestampAttributes.deletedAt) || null;
4266 const isSet = deletedAt !== defaultValue;
4267
4268 return isSet;
4269 }
4270
4271 /**
4272 * Restore the row corresponding to this instance. Only available for paranoid models.

Callers 3

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

Calls 1

getMethod · 0.95

Tested by

no test coverage detected