mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
ddc23b3467
refs https://github.com/TryGhost/Team/issues/3423 - This is a building block to allow paging, querying etc. of the posts belonging to a collection
27 lines
676 B
TypeScript
27 lines
676 B
TypeScript
import {InMemoryRepository} from '@tryghost/in-memory-repository';
|
|
|
|
type CollectionPost = {
|
|
id: string;
|
|
slug: string;
|
|
featured: boolean;
|
|
published_at: Date;
|
|
deleted: boolean;
|
|
};
|
|
|
|
export class PostsRepositoryInMemory extends InMemoryRepository<string, CollectionPost> {
|
|
protected toPrimitive(entity: CollectionPost): object {
|
|
return {
|
|
id: entity.id,
|
|
slug: entity.slug,
|
|
featured: entity.featured,
|
|
published_at: entity.published_at
|
|
};
|
|
}
|
|
|
|
getBulk(ids: string[]): Promise<CollectionPost[]> {
|
|
return this.getAll({
|
|
filter: `id:[${ids.join(',')}]`
|
|
});
|
|
}
|
|
}
|