Ghost/ghost/collections/test/fixtures/PostsRepositoryInMemory.ts
Fabien "egg" O'Carroll 9288f56649 Improved type definitions
The PostRepository type was using `any` (an anti pattern) rather than
`PostCollection`, and we had optional properties, which are not really
optional. This cleans up the types and updates the tests alongside them.
2023-07-27 16:33:16 +02:00

14 lines
494 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)
};
}
}