tethys.backend/app/Models/File.ts

77 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2023-03-03 15:54:28 +00:00
import { DateTime } from 'luxon';
import {
column,
hasMany,
HasMany,
belongsTo,
BelongsTo,
// manyToMany,
// ManyToMany,
SnakeCaseNamingStrategy,
2023-03-03 15:54:28 +00:00
} from '@ioc:Adonis/Lucid/Orm';
import HashValue from './HashValue';
import Dataset from './Dataset';
import BaseModel from './BaseModel';
2023-03-03 15:54:28 +00:00
export default class File extends BaseModel {
public static namingStrategy = new SnakeCaseNamingStrategy();
public static primaryKey = 'id';
public static table = 'document_files';
public static selfAssignPrimaryKey = false;
2023-03-03 15:54:28 +00:00
@column({
isPrimary: true,
})
public id: number;
2023-03-03 15:54:28 +00:00
@column({})
public document_id: number;
@column({})
public pathName: string;
2023-03-03 15:54:28 +00:00
@column()
public label: string;
2023-03-03 15:54:28 +00:00
@column()
public comment: string;
2023-03-03 15:54:28 +00:00
@column()
public mimeType: string;
2023-03-03 15:54:28 +00:00
@column()
public language: string;
2023-03-03 15:54:28 +00:00
@column()
public fileSize: number;
2023-03-03 15:54:28 +00:00
@column()
public visibleInOai: boolean;
2023-03-03 15:54:28 +00:00
@column()
public visibleInFrontdoor: boolean;
2023-03-03 15:54:28 +00:00
@column()
public sortOrder: number;
2023-03-03 15:54:28 +00:00
@column.dateTime({ autoCreate: true })
public createdAt: DateTime;
2023-03-03 15:54:28 +00:00
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime;
2023-03-03 15:54:28 +00:00
// public function dataset()
2023-03-03 15:54:28 +00:00
// {
// return $this->belongsTo(Dataset::class, 'document_id', 'id');
2023-03-03 15:54:28 +00:00
// }
@belongsTo(() => Dataset, {
foreignKey: 'document_id',
})
public dataset: BelongsTo<typeof Dataset>;
2023-03-03 15:54:28 +00:00
@hasMany(() => HashValue, {
foreignKey: 'file_id',
})
public hashvalues: HasMany<typeof HashValue>;
}