node-aws-utils
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -1,8 +0,18 @@ | ||
import { ResultOK, ResultFAIL } from 'node-result'; | ||
import { ReturningResultAsync } from 'node-result'; | ||
import { DynamoDB } from 'aws-sdk'; | ||
export declare class DynamoDocumentClient { | ||
static get(client: DynamoDB.DocumentClient, tableName: DynamoDB.DocumentClient.TableName, where: DynamoDB.DocumentClient.Key): Promise<ResultOK<DynamoDB.DocumentClient.AttributeMap | null> | ResultFAIL<Error>>; | ||
static get(client: DynamoDB.DocumentClient, tableName: DynamoDB.DocumentClient.TableName, where: DynamoDB.DocumentClient.Key): ReturningResultAsync<DynamoDB.DocumentClient.AttributeMap | null, Error>; | ||
static getFromIndex(client: DynamoDB.DocumentClient, tableName: DynamoDB.DocumentClient.TableName, indexName: DynamoDB.DocumentClient.IndexName, where: { | ||
pk: { | ||
name: DynamoDB.DocumentClient.AttributeName; | ||
value: DynamoDB.DocumentClient.AttributeValue; | ||
}; | ||
sk?: { | ||
name: DynamoDB.DocumentClient.AttributeName; | ||
value: DynamoDB.DocumentClient.AttributeValue; | ||
}; | ||
}): ReturningResultAsync<DynamoDB.DocumentClient.ItemList | null, Error>; | ||
static update(client: DynamoDB.DocumentClient, tableName: DynamoDB.DocumentClient.TableName, where: DynamoDB.DocumentClient.Key, data: { | ||
[key: string]: unknown; | ||
}): Promise<ResultOK<DynamoDB.DocumentClient.AttributeMap> | ResultFAIL<Error>>; | ||
}): ReturningResultAsync<DynamoDB.DocumentClient.AttributeMap, Error>; | ||
} |
@@ -20,2 +20,22 @@ "use strict"; | ||
} | ||
static async getFromIndex(client, tableName, indexName, where) { | ||
const params = { | ||
TableName: tableName, | ||
IndexName: indexName, | ||
KeyConditionExpression: '#PK = :pk', | ||
ExpressionAttributeNames: { | ||
'#PK': where.pk.name | ||
}, | ||
ExpressionAttributeValues: { | ||
':pk': where.pk.value | ||
} | ||
}; | ||
if (where.sk) { | ||
params.KeyConditionExpression += ` AND #SK = :sk`; | ||
params.ExpressionAttributeNames['#SK'] = where.sk.name; | ||
params.ExpressionAttributeValues[':sk'] = where.sk.value; | ||
} | ||
const { Items } = await client.query(params).promise(); | ||
return node_result_1.ResultOk(Items || null); | ||
} | ||
static async update(client, tableName, where, data) { | ||
@@ -58,3 +78,6 @@ const params = { | ||
node_result_1.tryCatchWrapperAsync | ||
], DynamoDocumentClient, "getFromIndex", null); | ||
__decorate([ | ||
node_result_1.tryCatchWrapperAsync | ||
], DynamoDocumentClient, "update", null); | ||
exports.DynamoDocumentClient = DynamoDocumentClient; |
{ | ||
"name": "node-aws-utils", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "aws utils", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"aws-sdk": "^2.822.0", | ||
"node-result": "^6.0.1" | ||
"node-result": "^8.0.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7508
99
+ Addednode-result@8.1.0(transitive)
- Removednode-result@6.2.0(transitive)
Updatednode-result@^8.0.0