@nu-art/ts-common 0.201.44 → 0.201.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,5 +4,6 @@ export declare const KeysOfDB_Object: (keyof DB_Object)[];
|
|
|
4
4
|
export declare function dbObjectToId(i: DB_Object): string;
|
|
5
5
|
export declare function dbObjectToId_V3<Proto extends DBProto<any>>(i: Proto['dbType']): any;
|
|
6
6
|
export declare function removeDBObjectKeys<T extends DB_Object>(instance: T): OmitDBObject<T>;
|
|
7
|
+
export declare function deleteKeysObject<T extends DB_Object, Ks extends keyof T>(instance: T, keysToRemove: Ks[]): Omit<T, Ks>;
|
|
7
8
|
export declare function keepDBObjectKeys<T extends DB_Object>(instance: T): DB_Object;
|
|
8
9
|
export declare function keepPartialObject<T extends TS_Object, Ks extends keyof T>(instance: T, keys: Ks[]): SubsetObjectByKeys<T, Ks>;
|
package/utils/db-object-tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keepPartialObject = exports.keepDBObjectKeys = exports.removeDBObjectKeys = exports.dbObjectToId_V3 = exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
|
|
3
|
+
exports.keepPartialObject = exports.keepDBObjectKeys = exports.deleteKeysObject = exports.removeDBObjectKeys = exports.dbObjectToId_V3 = exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
|
|
4
4
|
const object_tools_1 = require("./object-tools");
|
|
5
5
|
const tools_1 = require("./tools");
|
|
6
6
|
exports.KeysOfDB_Object = ['_id', '_v', '__created', '__updated'];
|
|
@@ -18,6 +18,12 @@ function removeDBObjectKeys(instance) {
|
|
|
18
18
|
return _instance;
|
|
19
19
|
}
|
|
20
20
|
exports.removeDBObjectKeys = removeDBObjectKeys;
|
|
21
|
+
function deleteKeysObject(instance, keysToRemove) {
|
|
22
|
+
const _instance = (0, object_tools_1.deepClone)(instance);
|
|
23
|
+
keysToRemove.forEach(key => delete _instance[key]);
|
|
24
|
+
return _instance;
|
|
25
|
+
}
|
|
26
|
+
exports.deleteKeysObject = deleteKeysObject;
|
|
21
27
|
function keepDBObjectKeys(instance) {
|
|
22
28
|
return keepPartialObject(instance, exports.KeysOfDB_Object);
|
|
23
29
|
}
|