mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
34 lines
773 B
TypeScript
34 lines
773 B
TypeScript
import AppBaseModel from '#models/app_base_model';
|
|
import Link from '#models/link';
|
|
import User from '#models/user';
|
|
import { belongsTo, column, manyToMany } from '@adonisjs/lucid/orm';
|
|
import type { BelongsTo, ManyToMany } from '@adonisjs/lucid/types/relations';
|
|
|
|
export default class Collection extends AppBaseModel {
|
|
@column()
|
|
declare name: string;
|
|
|
|
@column()
|
|
declare description: string | null;
|
|
|
|
@column()
|
|
declare visibility: Visibility;
|
|
|
|
@column()
|
|
declare nextId: string;
|
|
|
|
@column()
|
|
declare authorId: string;
|
|
|
|
@belongsTo(() => User, { foreignKey: 'authorId' })
|
|
declare author: BelongsTo<typeof User>;
|
|
|
|
@manyToMany(() => Link)
|
|
declare links: ManyToMany<typeof Link>;
|
|
}
|
|
|
|
export enum Visibility {
|
|
PUBLIC = 'PUBLIC',
|
|
PRIVATE = 'PRIVATE',
|
|
}
|