tethys.backend/app/Models/Dataset.ts
2023-03-03 16:54:28 +01:00

53 lines
1.2 KiB
TypeScript

import {
column,
BaseModel,
SnakeCaseNamingStrategy,
// computed,
manyToMany,
ManyToMany,
} from '@ioc:Adonis/Lucid/Orm';
import { DateTime } from 'luxon';
import Person from './Person';
export default class Dataset extends BaseModel {
public static namingStrategy = new SnakeCaseNamingStrategy();
public static primaryKey = 'id';
public static table = 'documents';
public static selfAssignPrimaryKey = false;
@column({ isPrimary: true })
public id: number;
@column({})
public server_state: boolean;
@column({})
public publisherName: string;
@column.dateTime({ columnName: 'embargo_date' })
public EmbargoDate: DateTime;
@column({})
public type: string;
@column.dateTime({ columnName: 'server_date_published' })
public ServerDatePublished: DateTime;
@column.dateTime({ autoCreate: true, columnName: 'created_at' })
public createdAt: DateTime;
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime;
@manyToMany(() => Person, {
pivotForeignKey: 'document_id',
pivotRelatedForeignKey: 'person_id',
pivotTable: 'link_documents_persons',
pivotColumns: ['role', 'sort_order', 'allow_email_contact']
})
public persons: ManyToMany<typeof Person>;
}