Skip to content

Commit

Permalink
fix: wrong format being persisted in database
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrdsilva committed May 26, 2024
1 parent ee0f52a commit d47e45a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/models/dtos/create-blog.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export class CreateBlogInput {
@IsNotEmpty({ message: 'The body field cannot be empty' })
body: string;

tags: string[];
tags: string;
}
17 changes: 12 additions & 5 deletions src/providers/blog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ export class BlogService {
) {}

async create(createBlogInput: CreateBlogInput, file: Express.Multer.File) {
const blog = this.blogRepository.create(createBlogInput);
const uploadedFile = await this.storageClientService.uploadFile(file).catch((error) => {
throw new InternalServerErrorException(error.message);
});
const blog = new Blog();

// const uploadedFile = await this.storageClientService.uploadFile(file).catch((error) => {
// throw new InternalServerErrorException(error.message);
// });

blog.filename = uploadedFile.filename;
// blog.filename = uploadedFile.filename;

blog.filename = "image.png";
blog.title = createBlogInput.title;
blog.description = createBlogInput.description;
blog.body = JSON.parse(createBlogInput.body);
blog.tags = JSON.parse(createBlogInput.tags);

return await this.blogRepository.save(blog);
}
Expand Down

0 comments on commit d47e45a

Please sign in to comment.