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
+25 -11
View File
@@ -1,15 +1,29 @@
import { User } from './User';
import { Auth } from './Auth';
import { UserPerms } from './UserPerms';
import { Post } from './Post';
import { Tag } from './Tag';
import { Attachment } from './Attachment';
import { Bucket } from './Bucket';
import { DBState } from './DBState';
import { Post, PostBucket } from './Post';
import { PostTag } from './PostTag';
import { Project } from './Project';
import { Tag } from './Tag';
import { User, addUserScopes } from './User';
import { UserPerms, addUserPermsScopes } from './UserPerms';
import { SqliteDialect } from '@sequelize/sqlite3';
import Sequelize from '@sequelize/core';
User.sync();
Auth.sync();
UserPerms.sync();
PostTag.sync();
Tag.sync();
Post.sync();
export { User, Auth, UserPerms, Post, Tag, PostTag }
const sequelize = new Sequelize({
dialect: SqliteDialect,
storage: 'db.sqlite',
models: [Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms],
});
const dbSync = (async ()=> await sequelize.sync())().then(()=>{
addUserScopes();
addUserPermsScopes();
});
export { sequelize, dbSync, Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms }