Refactored posts browsing to posts service

refs https://github.com/TryGhost/Team/issues/3423

- This refactor allow for smaller and cleaner change that's coming up when dealing with `?collection=` query parameter
This commit is contained in:
Naz 2023-06-16 14:52:39 +07:00
parent cfbc97b033
commit 1d214361ad
No known key found for this signature in database
2 changed files with 10 additions and 1 deletions

View File

@ -69,7 +69,7 @@ module.exports = {
unsafeAttrs: unsafeAttrs
},
query(frame) {
return models.Post.findPage(frame.options);
return postsService.browsePosts(frame.options);
}
},

View File

@ -27,6 +27,15 @@ class PostsService {
this.collectionsService = collectionsService;
}
/**
*
* @param {Object} options - frame options
* @returns {Promise<Object>}
*/
async browsePosts(options) {
return this.models.Post.findPage(options);
}
async readPost(frame) {
const model = await this.models.Post.findOne(frame.data, frame.options);