Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
55d96fa68d | |||
54ec6accdf |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@pushrocks/smartdata",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smartdata",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^4.0.20",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartdata",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"private": false,
|
||||
"description": "do more with data",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -14,7 +14,7 @@ export interface IDocValidationFunc<T> {
|
||||
(doc: T): boolean;
|
||||
}
|
||||
|
||||
export type TDelayedDbCreation = () => SmartdataDb;
|
||||
export type TDelayed<TDelayedArg> = () => 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<TManager>(dbArg: SmartdataDb | TDelayed<SmartdataDb>, managerArg?: TDelayed<TManager>) {
|
||||
return function classDecorator<T extends { new (...args: any[]): {} }>(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();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user