Working state for attachments and buckets

This commit is contained in:
2024-06-12 18:08:08 +02:00
parent e84ce38604
commit c72ac5e67f
5 changed files with 156 additions and 56 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Association, BelongsToGetAssociationMixin, BelongsToManyGetAssociationsMixin, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize, sql } from "@sequelize/core";
import { Post } from "./Post";
import { SqliteDialect } from '@sequelize/sqlite3';
import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, Default, NotNull, PrimaryKey, Unique } from "@sequelize/core/decorators-legacy";
import { Attachment } from "./Attachment";
import { UUID } from "crypto";
export class Bucket extends Model<InferAttributes<Bucket>, InferCreationAttributes<Bucket>> {
@PrimaryKey
@Unique
@Attribute(DataTypes.UUIDV4)
@Default(sql.uuidV4)
declare id: UUID
/** Defined by {@link Post.buckets} */
declare bucketPosts?:NonAttribute<Post>[];
/** Defined by {@link Attachment.bucket} */
declare attachments?:NonAttribute<Attachment>[];
declare static associations: {
bucketPosts: Association<Post, Bucket>;
attachments: Association<Attachment, Bucket>;
};
}
const sequelize = new Sequelize({
dialect: SqliteDialect,
storage: 'db.sqlite',
models: [Bucket]
})