mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
fix(server): ArchivableModel
This commit is contained in:
1 parent
e5e69838dc
commit
98687c0c64
2 files changed
+27
-7
No files matched your search
@@ -64,7 +64,7 @@ import Team from "./Team";
|
||||
import User from "./User";
|
||||
import UserMembership from "./UserMembership";
|
||||
import View from "./View";
|
||||
import ParanoidModel from "./base/ParanoidModel";
|
||||
import ArchivableModel from "./base/ArchivableModel";
|
||||
import Fix from "./decorators/Fix";
|
||||
import { DocumentHelper } from "./helpers/DocumentHelper";
|
||||
import IsHexColor from "./validators/IsHexColor";
|
||||
@@ -259,7 +259,7 @@ type AdditionalFindOptions = {
|
||||
}))
|
||||
@Table({ tableName: "documents", modelName: "document" })
|
||||
@Fix
|
||||
class Document extends ParanoidModel<
|
||||
class Document extends ArchivableModel<
|
||||
InferAttributes<Document>,
|
||||
Partial<InferCreationAttributes<Document>>
|
||||
> {
|
||||
@@ -362,11 +362,6 @@ class Document extends ParanoidModel<
|
||||
@Column(DataType.INTEGER)
|
||||
revisionCount: number;
|
||||
|
||||
/** Whether the document is archvied, and if so when. */
|
||||
@IsDate
|
||||
@Column
|
||||
archivedAt: Date | null;
|
||||
|
||||
/** Whether the document is published, and if so when. */
|
||||
@IsDate
|
||||
@Column
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/* 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 archvied, 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;
|
||||
Reference in new issue
Block a user