2023-03-03 15:54:28 +00:00
|
|
|
import { DateTime } from 'luxon';
|
|
|
|
import {
|
2023-06-22 15:20:04 +00:00
|
|
|
column,
|
|
|
|
BaseModel,
|
|
|
|
hasMany,
|
|
|
|
HasMany,
|
|
|
|
// manyToMany,
|
|
|
|
// ManyToMany,
|
|
|
|
SnakeCaseNamingStrategy,
|
2023-03-03 15:54:28 +00:00
|
|
|
} from '@ioc:Adonis/Lucid/Orm';
|
|
|
|
import HashValue from './HashValue';
|
|
|
|
|
|
|
|
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-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-06-22 15:20:04 +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-06-22 15:20:04 +00:00
|
|
|
public fileSize: bigint;
|
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
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
// public function hashvalues()
|
|
|
|
// {
|
|
|
|
// return $this->hasMany(HashValue::class, 'file_id', 'id');
|
|
|
|
// }
|
|
|
|
|
|
|
|
@hasMany(() => HashValue, {
|
|
|
|
foreignKey: 'file_id',
|
|
|
|
})
|
2023-06-22 15:20:04 +00:00
|
|
|
public hashvalues: HasMany<typeof HashValue>;
|
|
|
|
}
|