tethys.backend/app/Models/File.ts

64 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-03-03 15:54:28 +00:00
import { DateTime } from 'luxon';
import {
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 {
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 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: bigint;
2023-03-03 15:54:28 +00:00
@column()
public visibleInOai: 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 hashvalues()
// {
// return $this->hasMany(HashValue::class, 'file_id', 'id');
// }
@hasMany(() => HashValue, {
foreignKey: 'file_id',
})
public hashvalues: HasMany<typeof HashValue>;
}