diff --git a/src/core/Data.ts b/src/core/Data.ts index 97c44f88..9089302a 100644 --- a/src/core/Data.ts +++ b/src/core/Data.ts @@ -1,17 +1,18 @@ -const db = require('./db') +import { Collection } from 'mongodb' +import * as db from './db' -const store = new Map() +const store = new Map() export default class Data { - static setStore(Class, collection) { - store.set(Class, collection) + static setStore(key: string, collection: Collection) { + store.set(key, collection) } - static getStore(Class) { - return store.get(Class) + static getStore(key: string): Collection { + return store.get(key) } - static getCollection(name) { + static getCollection(name: string): Collection { return db.collection(name) } } diff --git a/src/core/Page.ts b/src/core/Page.ts index 4505bcc1..cdb2cc4f 100644 --- a/src/core/Page.ts +++ b/src/core/Page.ts @@ -3,7 +3,7 @@ import { find as storeFind, findOne, total } from '../lib/store' const Image = require('./Image') const Config = require('./Config') -const store = () => Data.getStore(Page) +const store = () => Data.getStore('Page') export default class Page { static async find(query, options = {}): Promise {