All files / src/store/factories store.factory.ts

50% Statements 6/12
0% Branches 0/2
0% Functions 0/1
60% Lines 6/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1x 1x 1x   1x   1x             1x  
'use strict';
 
import {Model} from 'mongoose';
 
import AStore from '../a.store';
import CountStore from '../count.store';
import DocumentStore from '../document.store';
import CollectionStore from '../collection.store';
import StoreScopeType from '../../_types/store.scope.type';
import CollectionsModelsMap from '../../mongodb/collections.models.map';
 
const storeFactory = (scope: StoreScopeType, observe: string, target: string): AStore => {
	const model: Model<any> = CollectionsModelsMap.getModelByCollection(observe);
 
	Iif (scope === 'many') return new CollectionStore(model, target);
	Iif (scope === 'count') return new CountStore(model, target);
	return new DocumentStore(model, target);
};
export default storeFactory;