Files
outline/server/models/base/ArchivableModel.ts
2024-09-06 12:09:21 +05:30

26 lines
658 B
TypeScript

/* eslint-disable @typescript-eslint/ban-types */
import { AllowNull, Column, IsDate } from "sequelize-typescript";
import ParanoidModel from "./ParanoidModel";
class ArchivableModel<
TModelAttributes extends {} = any,
TCreationAttributes extends {} = TModelAttributes
> extends ParanoidModel<TModelAttributes, TCreationAttributes> {
/** Whether the document is archived, and if so when. */
@AllowNull
@IsDate
@Column
archivedAt: Date | null;
/**
* Whether the model has been archived.
*
* @returns True if the model has been archived
*/
get isArchived() {
return !!this.archivedAt;
}
}
export default ArchivableModel;