mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
9b2a94f931
refs https://github.com/TryGhost/Arch/issues/95 Rather than storing all of the relations between the latest collection and posts, we know that it contains all posts. This means we don't have to keep the collections posts in sync. Instead we can fetch them from the posts table. This saves a lot of work during recalculation.
19 lines
611 B
TypeScript
19 lines
611 B
TypeScript
import {InMemoryRepository} from '@tryghost/in-memory-repository';
|
|
import {CollectionPost} from '../../src/CollectionPost';
|
|
|
|
export class PostsRepositoryInMemory extends InMemoryRepository<string, CollectionPost & {deleted: false}> {
|
|
protected toPrimitive(entity: CollectionPost): object {
|
|
return {
|
|
id: entity.id,
|
|
featured: entity.featured,
|
|
published_at: entity.published_at,
|
|
tags: entity.tags.map(tag => tag.slug)
|
|
};
|
|
}
|
|
|
|
async getAllIds() {
|
|
const posts = await this.getAll();
|
|
return posts.map(post => post.id);
|
|
}
|
|
}
|