Fixed error when including buckets on post query

This commit is contained in:
Andreas 2024-06-23 23:32:23 +02:00
parent 7fd4b8d3e2
commit 39f3c02e7c
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ export async function deletePost(postID: number): Promise<ActionResult<boolean>>
export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> { export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> {
await dbSync; await dbSync;
if(! await userIsAdmin()) return {error:"Unauthorized, not fetching Posts."} if(! await userIsAdmin()) return {error:"Unauthorized, not fetching Posts."}
const posts = await Post.findAll({include: {association: Post.associations.postBuckets, include: Bucket.associations.attachments}},); const posts = await Post.findAll({include: {association: Post.associations.buckets, include: Bucket.associations.attachments}},);
return {result:JSON.parse(JSON.stringify(posts))}; return {result:JSON.parse(JSON.stringify(posts))};
} }

View File

@ -67,7 +67,7 @@ export class Post extends Model<InferAttributes<Post>, InferCreationAttributes<P
declare static associations: { declare static associations: {
user: Association<User, Post>; user: Association<User, Post>;
project: Association<Project, Post>; project: Association<Project, Post>;
postBuckets: Association<Bucket, Post> buckets: Association<Bucket, Post>
postTags: Association<Tag, Post>; postTags: Association<Tag, Post>;
}; };