finally got the associations to work through black magic

This commit is contained in:
2024-06-13 07:03:38 +02:00
parent c72ac5e67f
commit 21e31d0ee4
16 changed files with 98 additions and 144 deletions
+4 -9
View File
@@ -1,4 +1,4 @@
import { Association, BelongsToGetAssociationMixin, BelongsToManyGetAssociationsMixin, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize, sql } from "@sequelize/core";
import { Association, BelongsToGetAssociationMixin, BelongsToManyAddAssociationMixin, BelongsToManyCreateAssociationMixin, BelongsToManyGetAssociationsMixin, BelongsToManyRemoveAssociationMixin, BelongsToManySetAssociationsMixin, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize, sql } from "@sequelize/core";
import { Post } from "./Post";
import { SqliteDialect } from '@sequelize/sqlite3';
@@ -14,19 +14,14 @@ export class Bucket extends Model<InferAttributes<Bucket>, InferCreationAttribut
declare id: UUID
/** Defined by {@link Post.buckets} */
declare bucketPosts?:NonAttribute<Post>[];
declare posts?:NonAttribute<Post>[];
/** Defined by {@link Attachment.bucket} */
declare attachments?:NonAttribute<Attachment>[];
declare static associations: {
bucketPosts: Association<Post, Bucket>;
posts: Association<Post, Bucket>;
attachments: Association<Attachment, Bucket>;
};
}
const sequelize = new Sequelize({
dialect: SqliteDialect,
storage: 'db.sqlite',
models: [Bucket]
})