forked from geolba/tethys.backend
- additional functionality for DatasetController.ts
- additional validation rules like 'uniqueArray' - additional Lucid models like BaseModel.ts for filling attributes, Title.ts, Description.ts - npm updates for @adonisjs/core
This commit is contained in:
parent
c4f4eff0d9
commit
e0ff71b117
44 changed files with 2002 additions and 1556 deletions
|
@ -1,52 +1,108 @@
|
|||
import {
|
||||
column,
|
||||
BaseModel,
|
||||
SnakeCaseNamingStrategy,
|
||||
// computed,
|
||||
manyToMany,
|
||||
ManyToMany,
|
||||
column,
|
||||
BaseModel,
|
||||
SnakeCaseNamingStrategy,
|
||||
manyToMany,
|
||||
ManyToMany,
|
||||
belongsTo,
|
||||
BelongsTo,
|
||||
hasMany,
|
||||
HasMany,
|
||||
} from '@ioc:Adonis/Lucid/Orm';
|
||||
import { DateTime } from 'luxon';
|
||||
import Person from './Person';
|
||||
|
||||
import User from './User';
|
||||
import Title from './Title';
|
||||
import Description from './Description';
|
||||
import License from './License';
|
||||
import Subject from './Subject';
|
||||
|
||||
export default class Dataset extends BaseModel {
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
public static primaryKey = 'id';
|
||||
public static table = 'documents';
|
||||
public static selfAssignPrimaryKey = false;
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
public static primaryKey = 'id';
|
||||
public static table = 'documents';
|
||||
public static selfAssignPrimaryKey = false;
|
||||
|
||||
@column({ isPrimary: true })
|
||||
public id: number;
|
||||
@column({ isPrimary: true })
|
||||
public id: number;
|
||||
|
||||
@column({})
|
||||
public server_state: boolean;
|
||||
public server_state: boolean;
|
||||
|
||||
@column({})
|
||||
public publisherName: string;
|
||||
public publisherName: string;
|
||||
|
||||
@column({ columnName: 'creating_corporation' })
|
||||
public creatingCorporation: string;
|
||||
|
||||
@column.dateTime({ columnName: 'embargo_date' })
|
||||
public embargoDate: DateTime;
|
||||
public embargoDate: DateTime;
|
||||
|
||||
@column({})
|
||||
public type: string;
|
||||
public type: string;
|
||||
|
||||
@column({})
|
||||
public language: string;
|
||||
|
||||
@column.dateTime({ columnName: 'server_date_published' })
|
||||
public serverDatePublished: DateTime;
|
||||
@column({})
|
||||
public account_id: number | null = null;
|
||||
|
||||
@column.dateTime({ autoCreate: true, columnName: 'created_at' })
|
||||
public createdAt: DateTime;
|
||||
@column.dateTime({ columnName: 'server_date_published' })
|
||||
public serverDatePublished: DateTime;
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime;
|
||||
@column.dateTime({ autoCreate: true, columnName: 'created_at' })
|
||||
public createdAt: DateTime;
|
||||
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true, columnName: 'server_date_modified' })
|
||||
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>;
|
||||
pivotForeignKey: 'document_id',
|
||||
pivotRelatedForeignKey: 'person_id',
|
||||
pivotTable: 'link_documents_persons',
|
||||
pivotColumns: ['role', 'sort_order', 'allow_email_contact'],
|
||||
})
|
||||
public persons: ManyToMany<typeof Person>;
|
||||
|
||||
/**
|
||||
* Get the account that the dataset belongs to
|
||||
*/
|
||||
@belongsTo(() => User, {
|
||||
foreignKey: 'account_id',
|
||||
})
|
||||
public user: BelongsTo<typeof User>;
|
||||
|
||||
@hasMany(() => Title, {
|
||||
foreignKey: 'document_id',
|
||||
})
|
||||
public titles: HasMany<typeof Title>;
|
||||
|
||||
@hasMany(() => Description, {
|
||||
foreignKey: 'document_id',
|
||||
})
|
||||
public descriptions: HasMany<typeof Description>;
|
||||
|
||||
@manyToMany(() => License, {
|
||||
pivotForeignKey: 'document_id',
|
||||
pivotRelatedForeignKey: 'licence_id',
|
||||
pivotTable: 'link_documents_licences',
|
||||
})
|
||||
public licenses: ManyToMany<typeof License>;
|
||||
|
||||
// public function subjects()
|
||||
// {
|
||||
// return $this->belongsToMany(\App\Models\Subject::class, 'link_dataset_subjects', 'document_id', 'subject_id');
|
||||
// }
|
||||
@manyToMany(() => Subject, {
|
||||
pivotForeignKey: 'document_id',
|
||||
pivotRelatedForeignKey: 'subject_id',
|
||||
pivotTable: 'link_dataset_subjects',
|
||||
})
|
||||
public subjects: ManyToMany<typeof Subject>;
|
||||
|
||||
// async save(): Promise<this> {
|
||||
// // Call the parent save method to persist changes to the database
|
||||
// await super.save();
|
||||
// return this;
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue