core Data typings

This commit is contained in:
tmshv committed 2019-10-15 00:35:27 +03:00
1 parent bf1fd90133
commit 717540682d
2 files changed
+9 -8

No files matched your search

+8 -7
View File
@@ -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<string, Collection>()
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)
}
}
+1 -1
View File
@@ -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<Page[]> {