Update CollectionsService to remove CollectionPost usage

This commit is contained in:
Fabien "egg" O'Carroll 2023-06-01 00:15:36 -04:00 committed by naz
parent 27f60b4ab5
commit bd4fac451c
3 changed files with 0 additions and 77 deletions

View File

@ -1,47 +0,0 @@
import {ValidationError} from '@tryghost/errors';
import tpl from '@tryghost/tpl';
import ObjectID from 'bson-objectid';
const messages = {
invalidIDProvided: 'Invalid ID provided for CollectionPost'
};
export class CollectionPost {
id: string;
postId: string;
collectionId: string;
sortOrder: number;
deleted: boolean;
constructor(data: any) {
this.id = data.id;
this.postId = data.postId;
this.collectionId = data.collectionId;
this.sortOrder = data.sortOder;
this.deleted = data.deleted;
}
static async create(data: any): Promise<CollectionPost> {
let id;
if (!data.id) {
id = new ObjectID();
} else if (typeof data.id === 'string') {
id = ObjectID.createFromHexString(data.id);
} else if (data.id instanceof ObjectID) {
id = data.id;
} else {
throw new ValidationError({
message: tpl(messages.invalidIDProvided)
});
}
return new CollectionPost({
id: id.toHexString(),
postId: data.post_id,
collectionId: data.collection_id,
sortOrder: data.sort_order, // NOTE: make sort_order required during creation
deleted: false
});
}
}

View File

@ -1,17 +0,0 @@
import {InMemoryRepository} from '@tryghost/in-memory-repository';
import {CollectionPost} from './CollectionPost';
export class CollectionsPostsRepositoryInMemory extends InMemoryRepository<string, CollectionPost> {
constructor() {
super();
}
protected toPrimitive(entity: CollectionPost): object {
return {
id: entity.id,
post_id: entity.postId,
collection_id: entity.collectionId,
sort_order: entity.sortOrder
};
}
}

View File

@ -1,20 +1,7 @@
import {InMemoryRepository} from '@tryghost/in-memory-repository';
import {Collection} from './Collection';
import {CollectionPost} from './CollectionPost';
export class CollectionsRepositoryInMemory extends InMemoryRepository<string, Collection> {
collectionsPostsRepository: any;
constructor(deps: any) {
super();
this.collectionsPostsRepository = deps.collectionsPostsRepository;
}
async saveCollectionPost(collectionPost: CollectionPost) {
await this.collectionsPostsRepository.save(collectionPost);
}
protected toPrimitive(entity: Collection): object {
return {
title: entity.title,