Removed unnecessary getBulk in PostsRepository

refs https://github.com/TryGhost/Arch/issues/16

- The method ended up being used only once, so it makes no sense to complicate the interface without any gain.
This commit is contained in:
Naz 2023-07-31 20:30:05 +08:00 committed by naz
parent 8635f4efeb
commit fe4c0b18cf
2 changed files with 4 additions and 9 deletions

View File

@ -105,7 +105,6 @@ type QueryOptions = {
interface PostsRepository {
getAll(options: QueryOptions): Promise<CollectionPost[]>;
getBulk(ids: string[], transaction?: Knex.Transaction): Promise<CollectionPost[]>;
}
export class CollectionsService {
@ -392,8 +391,10 @@ export class CollectionsService {
}
async updatePostsInCollections(postIds: string[], collections: Collection[], transaction: Knex.Transaction) {
const posts = await this.postsRepository.getBulk(postIds, transaction);
const posts = await this.postsRepository.getAll({
filter: `id:[${postIds.join(',')}]`,
transaction: transaction
});
for (const collection of collections) {
for (const post of posts) {

View File

@ -10,10 +10,4 @@ export class PostsRepositoryInMemory extends InMemoryRepository<string, Collecti
tags: entity.tags.map(tag => tag.slug)
};
}
async getBulk(ids: string[]) {
return this.getAll({
filter: `id:[${ids.join(',')}]`
});
}
}