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