mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
chore: create user, collection and link models, migrations and seeders
This commit is contained in:
33
app/models/collection.ts
Normal file
33
app/models/collection.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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',
|
||||
}
|
||||
Reference in New Issue
Block a user