From b6594de18cce7ef92cdd0dd33daa36619cab4442 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 31 May 2024 18:25:51 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/smartdata.classes.doc.ts | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 8f9d25f..5b83135 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartdata', - version: '5.2.1', + version: '5.2.2', description: 'An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.' } diff --git a/ts/smartdata.classes.doc.ts b/ts/smartdata.classes.doc.ts index d31a347..680988c 100644 --- a/ts/smartdata.classes.doc.ts +++ b/ts/smartdata.classes.doc.ts @@ -13,10 +13,10 @@ export type TDocCreation = 'db' | 'new' | 'mixed'; export function svDb() { return (target: SmartDataDbDoc, key: string) => { console.log(`called svDb() on >${target.constructor.name}.${key}<`); - if (!target.saveableProperties) { - target.saveableProperties = []; + if (!target.constructor.prototype.saveableProperties) { + target.constructor.prototype.saveableProperties = []; } - target.saveableProperties.push(key); + target.constructor.prototype.saveableProperties.push(key); }; } @@ -28,16 +28,16 @@ export function unI() { console.log(`called unI on >>${target.constructor.name}.${key}<<`); // mark the index as unique - if (!target.uniqueIndexes) { - target.uniqueIndexes = []; + if (!target.constructor.prototype.uniqueIndexes) { + target.constructor.prototype.uniqueIndexes = []; } - target.uniqueIndexes.push(key); + target.constructor.prototype.uniqueIndexes.push(key); // and also save it - if (!target.saveableProperties) { - target.saveableProperties = []; + if (!target.constructor.prototype.saveableProperties) { + target.constructor.prototype.saveableProperties = []; } - target.saveableProperties.push(key); + target.constructor.prototype.saveableProperties.push(key); }; } @@ -301,7 +301,7 @@ export class SmartDataDbDoc { const saveableObject: unknown = {}; // is not exposed to outside, so any is ok here - for (const propertyNameString of this.saveableProperties) { + for (const propertyNameString of this.constructor.prototype.saveableProperties) { saveableObject[propertyNameString] = this[propertyNameString]; } return saveableObject as TImplements;