inlaweb-lib-dynamodb 1.0.6 → 1.0.8

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +16 -9
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare class DynamoLib {
13
13
  permission?: string;
14
14
  username?: string;
15
15
  }): Promise<T[]>;
16
+ deleteItem(tableName: string, key: KeyValue): Promise<void>;
16
17
  private buildQueryParams;
17
18
  private buildExpressions;
18
19
  private buildFilterExpression;
package/index.js CHANGED
@@ -84,6 +84,22 @@ class DynamoLib {
84
84
  throw error;
85
85
  }
86
86
  }
87
+ async deleteItem(tableName, key) {
88
+ try {
89
+ const params = {
90
+ TableName: tableName,
91
+ Key: key,
92
+ ReturnConsumedCapacity: "TOTAL",
93
+ };
94
+ this.logger.debug(`DeleteItem: ${JSON.stringify(params)}`);
95
+ const response = await this.docClient.send(new lib_dynamodb_1.DeleteCommand(params));
96
+ this.logger.debug(`DeleteItem Result: ${JSON.stringify(response)}`);
97
+ }
98
+ catch (error) {
99
+ this.logger.error(error.message);
100
+ throw error;
101
+ }
102
+ }
87
103
  buildQueryParams(params) {
88
104
  const projection = this.buildProjectionExpression(params.searchParameters.projectionExpression);
89
105
  const parameters = {
@@ -247,15 +263,6 @@ class DynamoLib {
247
263
  }
248
264
  createUpdateParams(params) {
249
265
  const { table, PK, SK, item, setAttributes, addAttributes, removeAttributes, username, } = params;
250
- // Se agregan los datos de auditoría para la actualización
251
- item.updateUser = username;
252
- item.updateDate = moment_timezone_1.default
253
- .tz(new Date(), "America/Bogota")
254
- .format("YYYY-MM-DD");
255
- if (!setAttributes.includes("updateUser"))
256
- setAttributes.push("updateUser");
257
- if (!setAttributes.includes("updateDate"))
258
- setAttributes.push("updateDate");
259
266
  // Se crea el objeto de la operación
260
267
  let itemUpdate = {
261
268
  Update: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inlaweb-lib-dynamodb",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "scripts": {