From 54ec6accdf52a8e32e1836de71401294eda704f1 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 9 Jun 2021 12:40:55 +0200 Subject: [PATCH] fix(core): update --- ts/smartdata.classes.collection.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ts/smartdata.classes.collection.ts b/ts/smartdata.classes.collection.ts index 645ff34..14f9c7a 100644 --- a/ts/smartdata.classes.collection.ts +++ b/ts/smartdata.classes.collection.ts @@ -14,7 +14,7 @@ export interface IDocValidationFunc { (doc: T): boolean; } -export type TDelayedDbCreation = () => SmartdataDb; +export type TDelayed = () => TDelayedArg; const collectionFactory = new CollectionFactory(); @@ -22,7 +22,7 @@ const collectionFactory = new CollectionFactory(); * This is a decorator that will tell the decorated class what dbTable to use * @param dbArg */ -export function Collection(dbArg: SmartdataDb | TDelayedDbCreation) { +export function Collection(dbArg: SmartdataDb | TDelayed, managerArg?: TDelayed) { return function classDecorator(constructor: T) { return class extends constructor { public static get collection() { @@ -31,6 +31,11 @@ export function Collection(dbArg: SmartdataDb | TDelayedDbCreation) { public get collection() { return collectionFactory.getCollection(constructor.name, dbArg); } + public get manager() { + if (managerArg) { + return managerArg(); + } + } }; }; }