fix(collectionfactory): Simplify CollectionFactory.getCollection: remove unnecessary IIFE and instantiate collection only when dbArg is SmartdataDb

This commit is contained in:
2025-11-28 07:53:15 +00:00
parent 3f5101c061
commit ef5491075f
4 changed files with 59 additions and 44 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartdata',
version: '7.0.1',
version: '7.0.2',
description: 'An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.'
}

View File

@@ -6,13 +6,8 @@ export class CollectionFactory {
public collections: { [key: string]: SmartdataCollection<any> } = {};
public getCollection = (nameArg: string, dbArg: SmartdataDb): SmartdataCollection<any> => {
if (!this.collections[nameArg]) {
this.collections[nameArg] = (() => {
if (dbArg instanceof SmartdataDb) {
// tslint:disable-next-line: no-string-literal
return new SmartdataCollection(nameArg, dbArg);
}
})();
if (!this.collections[nameArg] && dbArg instanceof SmartdataDb) {
this.collections[nameArg] = new SmartdataCollection(nameArg, dbArg);
}
return this.collections[nameArg];
};