chore: create user, collection and link models, migrations and seeders

This commit is contained in:
Sonny
2024-04-28 00:45:10 +02:00
committed by Sonny
parent 08dcd7455f
commit 231629f0dd
17 changed files with 311 additions and 32 deletions

33
app/models/collection.ts Normal file
View 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',
}