2023-03-03 15:54:28 +00:00
|
|
|
import { DateTime } from 'luxon';
|
|
|
|
import {
|
2023-06-22 15:20:04 +00:00
|
|
|
column,
|
|
|
|
hasMany,
|
|
|
|
HasMany,
|
2023-06-27 16:23:18 +00:00
|
|
|
belongsTo,
|
|
|
|
BelongsTo,
|
2023-06-22 15:20:04 +00:00
|
|
|
// manyToMany,
|
|
|
|
// ManyToMany,
|
|
|
|
SnakeCaseNamingStrategy,
|
2023-03-03 15:54:28 +00:00
|
|
|
} from '@ioc:Adonis/Lucid/Orm';
|
|
|
|
import HashValue from './HashValue';
|
2023-06-27 16:23:18 +00:00
|
|
|
import Dataset from './Dataset';
|
2023-09-26 15:53:00 +00:00
|
|
|
import BaseModel from './BaseModel';
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
export default class File extends BaseModel {
|
2023-06-22 15:20:04 +00:00
|
|
|
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
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
@column({
|
|
|
|
isPrimary: true,
|
|
|
|
})
|
|
|
|
public id: number;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-27 16:23:18 +00:00
|
|
|
@column({})
|
|
|
|
public document_id: number;
|
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
@column({})
|
|
|
|
public pathName: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
@column()
|
|
|
|
public label: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column()
|
2023-06-22 15:20:04 +00:00
|
|
|
public comment: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column()
|
2023-09-04 11:24:58 +00:00
|
|
|
public mimeType: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column()
|
2023-06-22 15:20:04 +00:00
|
|
|
public language: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column()
|
2023-09-04 11:24:58 +00:00
|
|
|
public fileSize: number;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column()
|
2023-06-22 15:20:04 +00:00
|
|
|
public visibleInOai: boolean;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-09-04 11:24:58 +00:00
|
|
|
@column()
|
|
|
|
public visibleInFrontdoor: boolean;
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
@column()
|
2023-06-22 15:20:04 +00:00
|
|
|
public sortOrder: number;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@column.dateTime({ autoCreate: true })
|
2023-06-22 15:20:04 +00:00
|
|
|
public createdAt: DateTime;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
|
|
public updatedAt: DateTime;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-27 16:23:18 +00:00
|
|
|
// public function dataset()
|
2023-03-03 15:54:28 +00:00
|
|
|
// {
|
2023-06-27 16:23:18 +00:00
|
|
|
// return $this->belongsTo(Dataset::class, 'document_id', 'id');
|
2023-03-03 15:54:28 +00:00
|
|
|
// }
|
2023-06-27 16:23:18 +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',
|
|
|
|
})
|
2023-06-22 15:20:04 +00:00
|
|
|
public hashvalues: HasMany<typeof HashValue>;
|
|
|
|
}
|