@sdflc/backend-helpers 1.0.119 → 1.0.120
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.
|
@@ -129,3 +129,22 @@ export declare const addLang: (table: any, opt?: any) => any;
|
|
|
129
129
|
* @returns Plain object with default field values
|
|
130
130
|
*/
|
|
131
131
|
export declare const defaultFields: (opt?: any) => Record<string, any>;
|
|
132
|
+
/**
|
|
133
|
+
* Utility function to remove standard system fields from an object.
|
|
134
|
+
*
|
|
135
|
+
* Useful for preparing database records for output or comparison by stripping
|
|
136
|
+
* out fields that are automatically managed by the system and not relevant to
|
|
137
|
+
* business logic.
|
|
138
|
+
*
|
|
139
|
+
* Fields removed:
|
|
140
|
+
* - createdAt, createdBy, updatedAt, updatedBy, removedAt, removedBy,
|
|
141
|
+
* version, removedAtStr
|
|
142
|
+
*
|
|
143
|
+
* @param obj Input object (e.g. a database record)
|
|
144
|
+
* @returns New object with system fields omitted
|
|
145
|
+
*
|
|
146
|
+
* Note: this function does not modify the input object; it returns a new
|
|
147
|
+
* object with the specified fields removed. This is important for avoiding
|
|
148
|
+
* unintended side effects when working with database records.
|
|
149
|
+
* */
|
|
150
|
+
export declare const removeSystemTableFields: (obj: any) => any;
|
package/build/dbTableHelpers.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ./src/dbFieldHelpers.ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.defaultFields = exports.addLang = exports.addAccountId = exports.addUserId = exports.addSpaceId = exports.addAmount = exports.addOrderNoNum = exports.addOrderNo = exports.dbFieldAddDefaults = void 0;
|
|
4
|
+
exports.removeSystemTableFields = exports.defaultFields = exports.addLang = exports.addAccountId = exports.addUserId = exports.addSpaceId = exports.addAmount = exports.addOrderNoNum = exports.addOrderNo = exports.dbFieldAddDefaults = void 0;
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
5
6
|
const utils_1 = require("@sdflc/utils");
|
|
6
7
|
const constants_1 = require("./constants");
|
|
7
8
|
/**
|
|
@@ -254,3 +255,37 @@ const defaultFields = (opt) => {
|
|
|
254
255
|
return obj;
|
|
255
256
|
};
|
|
256
257
|
exports.defaultFields = defaultFields;
|
|
258
|
+
/**
|
|
259
|
+
* Utility function to remove standard system fields from an object.
|
|
260
|
+
*
|
|
261
|
+
* Useful for preparing database records for output or comparison by stripping
|
|
262
|
+
* out fields that are automatically managed by the system and not relevant to
|
|
263
|
+
* business logic.
|
|
264
|
+
*
|
|
265
|
+
* Fields removed:
|
|
266
|
+
* - createdAt, createdBy, updatedAt, updatedBy, removedAt, removedBy,
|
|
267
|
+
* version, removedAtStr
|
|
268
|
+
*
|
|
269
|
+
* @param obj Input object (e.g. a database record)
|
|
270
|
+
* @returns New object with system fields omitted
|
|
271
|
+
*
|
|
272
|
+
* Note: this function does not modify the input object; it returns a new
|
|
273
|
+
* object with the specified fields removed. This is important for avoiding
|
|
274
|
+
* unintended side effects when working with database records.
|
|
275
|
+
* */
|
|
276
|
+
const removeSystemTableFields = (obj) => {
|
|
277
|
+
if (!obj) {
|
|
278
|
+
return obj;
|
|
279
|
+
}
|
|
280
|
+
return (0, lodash_1.omit)(obj, [
|
|
281
|
+
'createdAt',
|
|
282
|
+
'createdBy',
|
|
283
|
+
'updatedAt',
|
|
284
|
+
'updatedBy',
|
|
285
|
+
'removedAt',
|
|
286
|
+
'removedBy',
|
|
287
|
+
'version',
|
|
288
|
+
'removedAtStr',
|
|
289
|
+
]);
|
|
290
|
+
};
|
|
291
|
+
exports.removeSystemTableFields = removeSystemTableFields;
|
|
@@ -129,3 +129,22 @@ export declare const addLang: (table: any, opt?: any) => any;
|
|
|
129
129
|
* @returns Plain object with default field values
|
|
130
130
|
*/
|
|
131
131
|
export declare const defaultFields: (opt?: any) => Record<string, any>;
|
|
132
|
+
/**
|
|
133
|
+
* Utility function to remove standard system fields from an object.
|
|
134
|
+
*
|
|
135
|
+
* Useful for preparing database records for output or comparison by stripping
|
|
136
|
+
* out fields that are automatically managed by the system and not relevant to
|
|
137
|
+
* business logic.
|
|
138
|
+
*
|
|
139
|
+
* Fields removed:
|
|
140
|
+
* - createdAt, createdBy, updatedAt, updatedBy, removedAt, removedBy,
|
|
141
|
+
* version, removedAtStr
|
|
142
|
+
*
|
|
143
|
+
* @param obj Input object (e.g. a database record)
|
|
144
|
+
* @returns New object with system fields omitted
|
|
145
|
+
*
|
|
146
|
+
* Note: this function does not modify the input object; it returns a new
|
|
147
|
+
* object with the specified fields removed. This is important for avoiding
|
|
148
|
+
* unintended side effects when working with database records.
|
|
149
|
+
* */
|
|
150
|
+
export declare const removeSystemTableFields: (obj: any) => any;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ./src/dbFieldHelpers.ts
|
|
2
|
+
import { omit } from 'lodash';
|
|
2
3
|
import { STATUSES, UUID_EMPTY } from '@sdflc/utils';
|
|
3
4
|
import { DEFAULT_ORDER_NO, FIELDS } from './constants';
|
|
4
5
|
/**
|
|
@@ -242,3 +243,36 @@ export const defaultFields = (opt) => {
|
|
|
242
243
|
}
|
|
243
244
|
return obj;
|
|
244
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Utility function to remove standard system fields from an object.
|
|
248
|
+
*
|
|
249
|
+
* Useful for preparing database records for output or comparison by stripping
|
|
250
|
+
* out fields that are automatically managed by the system and not relevant to
|
|
251
|
+
* business logic.
|
|
252
|
+
*
|
|
253
|
+
* Fields removed:
|
|
254
|
+
* - createdAt, createdBy, updatedAt, updatedBy, removedAt, removedBy,
|
|
255
|
+
* version, removedAtStr
|
|
256
|
+
*
|
|
257
|
+
* @param obj Input object (e.g. a database record)
|
|
258
|
+
* @returns New object with system fields omitted
|
|
259
|
+
*
|
|
260
|
+
* Note: this function does not modify the input object; it returns a new
|
|
261
|
+
* object with the specified fields removed. This is important for avoiding
|
|
262
|
+
* unintended side effects when working with database records.
|
|
263
|
+
* */
|
|
264
|
+
export const removeSystemTableFields = (obj) => {
|
|
265
|
+
if (!obj) {
|
|
266
|
+
return obj;
|
|
267
|
+
}
|
|
268
|
+
return omit(obj, [
|
|
269
|
+
'createdAt',
|
|
270
|
+
'createdBy',
|
|
271
|
+
'updatedAt',
|
|
272
|
+
'updatedBy',
|
|
273
|
+
'removedAt',
|
|
274
|
+
'removedBy',
|
|
275
|
+
'version',
|
|
276
|
+
'removedAtStr',
|
|
277
|
+
]);
|
|
278
|
+
};
|