admin panel progress

This commit is contained in:
2024-06-08 00:21:53 +02:00
parent a0a938021d
commit 99c3267c04
24 changed files with 305 additions and 103 deletions
+40
View File
@@ -0,0 +1,40 @@
import { Association, Attributes, CreationAttributes, CreationOptional, DataTypes, HasManyGetAssociationsMixin, HasOneCreateAssociationMixin, HasOneGetAssociationMixin, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";
import {
PrimaryKey,
Attribute,
AutoIncrement,
NotNull,
BelongsTo,
Unique,
HasMany,
HasOne,
UpdatedAt,
CreatedAt,
} from '@sequelize/core/decorators-legacy';
import { SqliteDialect } from '@sequelize/sqlite3';
export class DBState extends Model<InferAttributes<DBState>, InferCreationAttributes<DBState>>{
@Attribute(DataTypes.INTEGER)
@PrimaryKey
@AutoIncrement
@Unique
declare id: CreationOptional<number>;
@Attribute(DataTypes.STRING)
declare version:number;
// Date thingies
@CreatedAt
declare createdAt: CreationOptional<Date>;
@UpdatedAt
declare updatedAt: CreationOptional<Date>;
}
const sequelize = new Sequelize({
dialect: SqliteDialect,
storage: 'db.sqlite',
models: [DBState]
});
+3 -3
View File
@@ -35,13 +35,13 @@ export class Post extends Model<InferAttributes<Post>, InferCreationAttributes<P
declare user_id:ForeignKey<User['id']>;
@Attribute(DataTypes.INTEGER)
declare project_id?:CreationOptional<ForeignKey<User['id']>>;
declare project_id:CreationOptional<ForeignKey<User['id']>>;
@BelongsTo(()=>User, { foreignKey: 'user_id', inverse: { type: 'hasMany', as: 'posts' } })
declare user:NonAttribute<User>;
@BelongsTo(()=>Project, { inverse: { type: 'hasMany', as: 'posts' } })
declare project:NonAttribute<User>;
@BelongsTo(()=>Project, { foreignKey:'project_id', inverse: { type: 'hasMany', as: 'posts' } })
declare project:CreationOptional<Project>;
@BelongsToMany(()=>Tag, { through: { model: ()=>PostTag, unique: false}, inverse: {as: 'taggedPosts'} })
declare postTags?:NonAttribute<Tag[]>;
+3 -2
View File
@@ -5,8 +5,8 @@ import { Attribute, AutoIncrement, PrimaryKey, Unique } from "@sequelize/core/de
import { Post } from "./Post";
export class Project extends Model<InferAttributes<Project>, InferCreationAttributes<Project>> {
@Attribute(DataTypes.INTEGER) @PrimaryKey @Unique @AutoIncrement
declare id: number;
@Attribute(DataTypes.INTEGER) @PrimaryKey @Unique @AutoIncrement
declare id: CreationOptional<number>;
@Attribute(DataTypes.STRING) @Unique
declare readableIdentifier: string;
@Attribute(DataTypes.STRING)
@@ -20,5 +20,6 @@ export class Project extends Model<InferAttributes<Project>, InferCreationAttrib
const sequelize = new Sequelize({
dialect: SqliteDialect,
storage: 'db.sqlite',
models: [Project]
})