add report page
This commit is contained in:
@@ -5,15 +5,17 @@ import * as bcrypt from 'bcrypt';
|
||||
import {
|
||||
BeforeCreate,
|
||||
BeforeUpdate,
|
||||
BelongsTo,
|
||||
Column,
|
||||
ForeignKey,
|
||||
Index,
|
||||
Model,
|
||||
Sequelize,
|
||||
Table,
|
||||
Unique
|
||||
Table
|
||||
} from 'sequelize-typescript';
|
||||
import { Permissions } from '$lib/permissions';
|
||||
|
||||
@Table({ modelName: 'user' })
|
||||
@Table({ modelName: 'user', underscored: true })
|
||||
export class User extends Model {
|
||||
@Column({ type: DataTypes.STRING, allowNull: false })
|
||||
declare firstname: string;
|
||||
@@ -30,10 +32,37 @@ export class User extends Model {
|
||||
@Column({ type: DataTypes.STRING })
|
||||
declare password: string;
|
||||
@Column({ type: DataTypes.UUIDV4 })
|
||||
@Index
|
||||
declare uuid: string;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'admin' })
|
||||
@Table({ modelName: 'report', underscored: true })
|
||||
export class Report extends Model {
|
||||
@Column({ type: DataTypes.STRING, allowNull: false, unique: true })
|
||||
@Index
|
||||
declare url_id: string;
|
||||
@Column({ type: DataTypes.STRING, allowNull: false })
|
||||
declare subject: string;
|
||||
@Column({ type: DataTypes.STRING })
|
||||
declare body: string;
|
||||
@Column({ type: DataTypes.BOOLEAN, allowNull: false })
|
||||
declare draft: boolean;
|
||||
@Column({ type: DataTypes.BOOLEAN, allowNull: false })
|
||||
declare completed: boolean;
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
@ForeignKey(() => User)
|
||||
declare reporter_user_id: number;
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
@ForeignKey(() => User)
|
||||
declare reported_user_id: number;
|
||||
|
||||
@BelongsTo(() => User)
|
||||
declare reporter: User;
|
||||
@BelongsTo(() => User)
|
||||
declare reported: User;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'admin', underscored: true })
|
||||
export class Admin extends Model {
|
||||
@Column({ type: DataTypes.STRING, allowNull: false, unique: true })
|
||||
declare username: string;
|
||||
@@ -68,5 +97,5 @@ export class Admin extends Model {
|
||||
export const sequelize = new Sequelize(building ? 'sqlite::memory:' : env.DATABASE_URI, {
|
||||
// only log sql queries in dev mode
|
||||
logging: dev ? console.log : false,
|
||||
models: [User, Admin]
|
||||
models: [User, Report, Admin]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user