0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Moved bookshelf posts repository to core

refs https://github.com/TryGhost/Team/issues/3260

- Moved the posts bookshelf repository into core codebase where it should belong.
This commit is contained in:
Naz 2023-05-31 13:39:43 +07:00 committed by naz
parent 4fe9e5fac0
commit 87df8754ee
5 changed files with 29 additions and 24 deletions

View file

@ -1,17 +0,0 @@
type PostsDataRepositoryBookshelfDeps = {
Post: any;
}
export class PostsDataRepositoryBookshelf {
Post;
constructor(deps: PostsDataRepositoryBookshelfDeps) {
this.Post = deps.Post;
}
async getBulk(ids: string[]) {
return await this.Post.fetchAll({
filter: `id:[${ids.join(',')}]`
});
}
}

View file

@ -1,5 +1,4 @@
export * from './CollectionsService';
export * from './CollectionsRepositoryInMemory';
export * from './PostsDataRepositoryInMemory';
export * from './PostsDataRepositoryBookshelf';
export * from './Collection';

View file

@ -0,0 +1,23 @@
class PostsDataRepositoryBookshelf {
Post;
/**
* @param {Object} deps
* @param {import('../../models/post')} deps.Post
*/
constructor(deps) {
this.Post = deps.Post;
}
/**
* @param {string[]} ids
* @returns {Promise<import('../../models/post')>}
**/
async getBulk(ids) {
return await this.Post.fetchAll({
filter: `id:[${ids.join(',')}]`
});
}
}
module.exports = PostsDataRepositoryBookshelf;

View file

@ -1,9 +1,9 @@
const models = require('../../models');
const {
CollectionsService,
CollectionsRepositoryInMemory,
PostsDataRepositoryBookshelf
CollectionsRepositoryInMemory
} = require('@tryghost/collections');
const PostsDataRepositoryBookshelf = require('./PostsDataRepositoryBookshelf');
class CollectionsServiceWrapper {
api;

View file

@ -1,9 +1,9 @@
import sinon from 'sinon';
import assert from 'assert';
import {PostsDataRepositoryBookshelf} from '../src/PostsDataRepositoryBookshelf';
const sinon = require('sinon');
const assert = require('assert');
const {PostsDataRepositoryBookshelf} = require('../../../../../core/server/services/collections/PostsDataRepositoryBookshelf');
describe('PostsDataRepositoryBookshelf', function () {
let Post: any;
let Post;
beforeEach(async function () {
Post = {