tethys.backend/app/Models/Dataset.ts

53 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-03-03 15:54:28 +00:00
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;
2023-03-03 15:54:28 +00:00
@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>;
}