mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { DateTime } from 'luxon'
|
|
import { BaseModel, belongsTo, column, SnakeCaseNamingStrategy } from '@adonisjs/lucid/orm'
|
|
import CuratedCollection from './curated_collection.js'
|
|
import type { BelongsTo } from '@adonisjs/lucid/types/relations'
|
|
|
|
export default class CuratedCollectionResource extends BaseModel {
|
|
static namingStrategy = new SnakeCaseNamingStrategy()
|
|
|
|
static indexes = [
|
|
{
|
|
name: 'curated_collection_resources_unique',
|
|
columns: ['curated_collection_slug', 'url'],
|
|
unique: true,
|
|
},
|
|
]
|
|
|
|
@column({ isPrimary: true })
|
|
declare id: number
|
|
|
|
@column()
|
|
declare curated_collection_slug: string
|
|
|
|
@belongsTo(() => CuratedCollection, {
|
|
foreignKey: 'slug',
|
|
localKey: 'curated_collection_slug',
|
|
})
|
|
declare curated_collection: BelongsTo<typeof CuratedCollection>
|
|
|
|
@column()
|
|
declare title: string
|
|
|
|
@column()
|
|
declare url: string
|
|
|
|
@column()
|
|
declare description: string
|
|
|
|
@column()
|
|
declare size_mb: number
|
|
|
|
@column()
|
|
declare downloaded: boolean
|
|
|
|
@column.dateTime({ autoCreate: true })
|
|
declare created_at: DateTime
|
|
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updated_at: DateTime
|
|
}
|