- add model DatasetReference.ts
All checks were successful
CI Pipeline / japa-tests (push) Successful in 48s
All checks were successful
CI Pipeline / japa-tests (push) Successful in 48s
- add references inside Creta.vue for Submitter /dataset - npm updates - extended enum types - added relations for Dataset.ts
This commit is contained in:
parent
5ce4f0b018
commit
f6d735d0fd
10 changed files with 580 additions and 592 deletions
|
@ -7,6 +7,21 @@ export default class Coverage extends BaseModel {
|
|||
public static primaryKey = 'id';
|
||||
public static table = 'coverage';
|
||||
public static selfAssignPrimaryKey = false;
|
||||
public static fillable: string[] = [
|
||||
'elevation_min',
|
||||
'elevation_max',
|
||||
'elevation_absolut',
|
||||
'depth_min',
|
||||
'depth_max',
|
||||
'depth_absolut',
|
||||
'time_min',
|
||||
'time_max',
|
||||
'time_absolut',
|
||||
'x_min',
|
||||
'x_max',
|
||||
'y_min',
|
||||
'y_max',
|
||||
];
|
||||
|
||||
@column({
|
||||
isPrimary: true,
|
||||
|
|
|
@ -22,6 +22,7 @@ import License from './License';
|
|||
import Subject from './Subject';
|
||||
import File from './File';
|
||||
import Coverage from './Coverage';
|
||||
import DatasetReference from './DatasetReference';
|
||||
|
||||
export default class Dataset extends BaseModel {
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
|
@ -138,6 +139,11 @@ export default class Dataset extends BaseModel {
|
|||
})
|
||||
public coverage: HasOne<typeof Coverage>;
|
||||
|
||||
@hasMany(() => DatasetReference, {
|
||||
foreignKey: 'document_id',
|
||||
})
|
||||
public references: HasMany<typeof DatasetReference>;
|
||||
|
||||
|
||||
@computed({
|
||||
serializeAs: 'main_title',
|
||||
|
|
49
app/Models/DatasetReference.ts
Normal file
49
app/Models/DatasetReference.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { column, BaseModel, SnakeCaseNamingStrategy, belongsTo, BelongsTo } from '@ioc:Adonis/Lucid/Orm';
|
||||
import { DateTime } from 'luxon';
|
||||
import Dataset from './Dataset';
|
||||
|
||||
export default class DatasetReference extends BaseModel {
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
public static primaryKey = 'id';
|
||||
public static table = 'document_references';
|
||||
public static fillable: string[] = ['value', 'label', 'type', 'relation'];
|
||||
|
||||
@column({
|
||||
isPrimary: true,
|
||||
})
|
||||
public id: number;
|
||||
|
||||
@column({})
|
||||
public document_id: number;
|
||||
|
||||
@column({})
|
||||
public related_document_id?: number;
|
||||
|
||||
@column({})
|
||||
public type: string;
|
||||
|
||||
@column({})
|
||||
public relation: string;
|
||||
|
||||
@column({})
|
||||
public value: string;
|
||||
|
||||
@column({})
|
||||
public label: string;
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
})
|
||||
public created_at?: DateTime;
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
autoUpdate: true,
|
||||
})
|
||||
public updated_at?: DateTime;
|
||||
|
||||
@belongsTo(() => Dataset, {
|
||||
foreignKey: 'document_id',
|
||||
})
|
||||
public dataset: BelongsTo<typeof Dataset>;
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue