* 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}
()
| 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. |
no test coverage detected