2024-03-14 19:25:27 +00:00
|
|
|
import { column, BaseModel, belongsTo, SnakeCaseNamingStrategy } from '@adonisjs/lucid/orm';
|
|
|
|
import File from './File.js';
|
|
|
|
import type { BelongsTo } from "@adonisjs/lucid/types/relations";
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
export default class HashValue extends BaseModel {
|
2023-06-22 15:20:04 +00:00
|
|
|
public static namingStrategy = new SnakeCaseNamingStrategy();
|
2023-11-22 16:06:55 +00:00
|
|
|
// public static primaryKey = 'file_id,type';
|
2023-06-22 15:20:04 +00:00
|
|
|
public static table = 'file_hashvalues';
|
|
|
|
|
2023-03-03 15:54:28 +00:00
|
|
|
// static get primaryKey () {
|
|
|
|
// return 'type, value'
|
|
|
|
// }
|
|
|
|
|
2023-07-17 17:13:30 +00:00
|
|
|
public static get incrementing() {
|
2023-06-22 15:20:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @column({
|
|
|
|
// isPrimary: true,
|
|
|
|
// })
|
|
|
|
// public id: number;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
// Foreign key is still on the same model
|
2023-11-22 16:06:55 +00:00
|
|
|
@column({ isPrimary: true })
|
2023-06-22 15:20:04 +00:00
|
|
|
public file_id: number;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-11-22 16:06:55 +00:00
|
|
|
@column({ isPrimary: true })
|
2023-06-22 15:20:04 +00:00
|
|
|
public type: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-06-22 15:20:04 +00:00
|
|
|
@column()
|
|
|
|
public value: string;
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
@belongsTo(() => File)
|
2023-06-22 15:20:04 +00:00
|
|
|
public file: BelongsTo<typeof File>;
|
|
|
|
}
|