Compare commits

..

5 Commits

3 changed files with 22 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/smartdata", "name": "@push.rocks/smartdata",
"version": "5.2.1", "version": "5.2.3",
"private": false, "private": false,
"description": "An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.", "description": "An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -13,14 +13,14 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/smartdata.git" "url": "https://code.foss.global/push.rocks/smartdata.git"
}, },
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartdata/issues" "url": "https://gitlab.com/pushrocks/smartdata/issues"
}, },
"homepage": "https://gitlab.com/pushrocks/smartdata#README", "homepage": "https://code.foss.global/push.rocks/smartdata",
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.0.14", "@push.rocks/lik": "^6.0.14",
"@push.rocks/smartdelay": "^3.0.1", "@push.rocks/smartdelay": "^3.0.1",

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartdata', name: '@push.rocks/smartdata',
version: '5.2.1', version: '5.2.3',
description: 'An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.' 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

@ -7,6 +7,16 @@ import { SmartdataDbWatcher } from './smartdata.classes.watcher.js';
export type TDocCreation = 'db' | 'new' | 'mixed'; export type TDocCreation = 'db' | 'new' | 'mixed';
export function globalSvDb() {
return (target: SmartDataDbDoc<unknown, unknown>, key: string) => {
console.log(`called svDb() on >${target.constructor.name}.${key}<`);
if (!target.globalSaveableProperties) {
target.globalSaveableProperties = [];
}
target.globalSaveableProperties.push(key);
};
}
/** /**
* saveable - saveable decorator to be used on class properties * saveable - saveable decorator to be used on class properties
*/ */
@ -202,22 +212,27 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
/** /**
* updated from db in any case where doc comes from db * updated from db in any case where doc comes from db
*/ */
@svDb() @globalSvDb()
_createdAt: string = (new Date()).toISOString(); _createdAt: string = (new Date()).toISOString();
/** /**
* will be updated everytime the doc is saved * will be updated everytime the doc is saved
*/ */
@svDb() @globalSvDb()
_updatedAt: string = (new Date()).toISOString(); _updatedAt: string = (new Date()).toISOString();
/**
* an array of saveable properties of ALL doc
*/
public globalSaveableProperties: string[];
/** /**
* unique indexes * unique indexes
*/ */
public uniqueIndexes: string[]; public uniqueIndexes: string[];
/** /**
* an array of saveable properties of a doc * an array of saveable properties of a specific doc
*/ */
public saveableProperties: string[]; public saveableProperties: string[];