From 50712e8c6cedaa9900897acc187a1237c76f5887 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 8 Feb 2018 01:21:10 +0000 Subject: further work on ORM model --- src/db/model/File.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/db/model/File.ts (limited to 'src/db/model/File.ts') diff --git a/src/db/model/File.ts b/src/db/model/File.ts new file mode 100644 index 0000000..b88fef4 --- /dev/null +++ b/src/db/model/File.ts @@ -0,0 +1,32 @@ +import * from 'sequelize-typescript'; + +@Table +export default class File extends Model { + @Column + @Unique + @NotNull + name: string; + + @Column + @PrimaryKey + uuid: string; + + @Column + mimetype: string; + + @Column + @ForeignKey(() => File) + parentFolderId: string; + + @BelongsTo(() => File) + parentFolder: File; + + @HasMany(() => File) + containedFiles: File[]; + + @CreatedAt + uploadDate: Date; + + @UpdatedAt + modifyDate: Date; +} -- cgit v1.2.1