fix(classes.collection): Guard against missing collection before attaching document constructor in Collection decorator

This commit is contained in:
2025-11-28 10:03:23 +00:00
parent 4cf62fd91c
commit fbb8bb685c
3 changed files with 8 additions and 2 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartdata',
version: '7.0.5',
version: '7.0.6',
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

@@ -41,7 +41,7 @@ export function Collection(dbArg: SmartdataDb | TDelayed<SmartdataDb>) {
}
const coll = collectionFactory.getCollection(constructor.name, dbArg);
// Attach document constructor for searchableFields lookup
if (!(coll as any).docCtor) {
if (coll && !(coll as any).docCtor) {
(coll as any).docCtor = decoratedClass;
}
return coll;