import { Association, BelongsToGetAssociationMixin, BelongsToManyAddAssociationMixin, BelongsToManyAssociation, BelongsToManyCreateAssociationMixin, BelongsToManyGetAssociationsMixin, BelongsToManyRemoveAssociationMixin, BelongsToManySetAssociationsMixin, CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";import { User } from "./User"; import { SqliteDialect } from '@sequelize/sqlite3'; import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, CreatedAt, Default, HasMany, NotNull, PrimaryKey, Unique, UpdatedAt } from "@sequelize/core/decorators-legacy"; import { Tag } from "./Tag"; import { PostTag } from "./PostTag"; import { Project } from "./Project"; import { Attachment } from "./Attachment"; import { Bucket } from "./Bucket"; import { UUID } from "crypto"; export class Post extends Model, InferCreationAttributes> { // Attributes @Attribute(DataTypes.INTEGER) @PrimaryKey @AutoIncrement @Unique declare id: CreationOptional; @Attribute(DataTypes.STRING) declare title:string @Attribute(DataTypes.STRING) declare content:string // Date thingies @CreatedAt declare createdAt: CreationOptional; @UpdatedAt declare updatedAt: CreationOptional; // Associatoins @Attribute(DataTypes.INTEGER) @NotNull declare user_id:ForeignKey; @Attribute(DataTypes.INTEGER) declare project_id:CreationOptional>; @BelongsTo(()=>User, { foreignKey: 'user_id', inverse: { type: 'hasMany', as: 'posts' } }) declare user:NonAttribute; @BelongsTo(()=>Project, { foreignKey:'project_id', inverse: { type: 'hasMany', as: 'posts' } }) declare project:CreationOptional; @BelongsToMany(()=>Tag, { through: { model: ()=>PostTag, unique: false}, inverse: {as: 'taggedPosts'} }) declare postTags?:NonAttribute; @BelongsToMany(()=>Bucket,{through: {model:'PostBucket'}, throughAssociations: { fromSource: 'postBucketBuckets', toSource: 'post', fromTarget: 'postBucketPosts', toTarget: 'PostBucket', }, inverse:{as: 'posts'}, foreignKey: 'postId', otherKey: 'bucketId'}) declare buckets?:NonAttribute; declare static associations: { user: Association; project: Association; postBuckets: Association postTags: Association; }; declare getUser: BelongsToGetAssociationMixin; declare getBuckets: BelongsToManyGetAssociationsMixin; declare setBuckets: BelongsToManySetAssociationsMixin; declare addBucket: BelongsToManyAddAssociationMixin; declare addBuckets: BelongsToManyAddAssociationMixin; declare removeBucket: BelongsToManyRemoveAssociationMixin; declare removeBuckets: BelongsToManyRemoveAssociationMixin; declare createBucket: BelongsToManyCreateAssociationMixin; } export class PostBucket extends Model, InferCreationAttributes> { declare postId: number; declare bucketId: UUID; declare post?:NonAttribute declare bucket?:NonAttribute }