add relations to blog post GET endpoint

This commit is contained in:
Lacey Pevey
2023-05-16 09:44:19 -05:00
parent f8fa01a41c
commit 0e110368f5
3 changed files with 21 additions and 2 deletions
+6
View File
@@ -1,5 +1,11 @@
# Change Log
## 0.0.3
### Patch Changes
- Add relations to blog post GET endpoint
## 0.0.2
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-blog",
"version": "0.0.2",
"version": "0.0.3",
"description": "Basic blog for Medusa",
"repository": {
"type": "git",
+14 -1
View File
@@ -85,13 +85,26 @@ export default class BlogService extends TransactionBaseService {
async getBlogPosts() {
/* @ts-ignore */
const blogPostRepository = this.activeManager_.withRepository(this.blogPostRepository_)
return await blogPostRepository.find()
return await blogPostRepository.find({
relations: {
category: true,
tags: true,
products: true,
collections: true
}
})
}
async getBlogPostsByCategory(category_id) {
/* @ts-ignore */
const blogPostRepository = this.activeManager_.withRepository(this.blogPostRepository_)
return await blogPostRepository.find({
relations: {
category: true,
tags: true,
products: true,
collections: true
},
where: { category_id }
})
}