@xapp/dynamo-service
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -5,2 +5,11 @@ # Changelog | ||
## [1.2.0](https://github.com/XappMedia/dynamo-service/compare/v1.1.0...v1.2.0) (2019-08-06) | ||
### Features | ||
* Query count ([6a03d2b](https://github.com/XappMedia/dynamo-service/commit/6a03d2b)) | ||
## [1.1.0](https://github.com/XappMedia/dynamo-service/compare/v0.2.3...v1.1.0) (2019-07-18) | ||
@@ -7,0 +16,0 @@ |
@@ -8,2 +8,5 @@ import { DynamoDB } from "aws-sdk"; | ||
} | ||
export interface QueryCountResult { | ||
Count: number; | ||
} | ||
export interface ScanResult<T> { | ||
@@ -23,2 +26,3 @@ Items: T[]; | ||
} | ||
export declare type QueryCountParams = Pick<QueryParams, "KeyConditionExpression" | "FilterExpression" | "ExpressionAttributeNames" | "ExpressionAttributeValues" | "IndexName">; | ||
export interface ScanParams { | ||
@@ -92,2 +96,3 @@ IndexName?: string; | ||
query<T>(table: string, myParams: QueryParams, projection: string[]): Promise<QueryResult<Partial<T>>>; | ||
count(table: string, myParams: QueryCountParams): Promise<QueryCountResult>; | ||
scan<T>(table: string, myParams: ScanParams): Promise<ScanResult<T>>; | ||
@@ -94,0 +99,0 @@ scan<T, P extends keyof T>(table: string, myParams: ScanParams, projection: P): Promise<ScanResult<Pick<T, P>>>; |
@@ -111,2 +111,16 @@ "use strict"; | ||
} | ||
count(table, myParams) { | ||
const params = { | ||
TableName: table, | ||
Select: "COUNT" | ||
}; | ||
addIfExists(params, myParams, [ | ||
"KeyConditionExpression", | ||
"FilterExpression", | ||
"ExpressionAttributeNames", | ||
"ExpressionAttributeValues", | ||
"IndexName" | ||
]); | ||
return this.db.query(params).promise(); | ||
} | ||
scan(table, myParams, projection) { | ||
@@ -113,0 +127,0 @@ const params = { |
import { DynamoDB } from "aws-sdk"; | ||
import { ConditionExpression, DynamoService, QueryParams, QueryResult, ScanParams, ScanResult, UpdateBody, UpdateReturnAllType, UpdateReturnNoneType, UpdateReturnType, UpdateReturnUpdatedType } from "../DynamoService"; | ||
import { ConditionExpression, DynamoService, QueryCountParams, QueryCountResult, QueryParams, QueryResult, ScanParams, ScanResult, UpdateBody, UpdateReturnAllType, UpdateReturnNoneType, UpdateReturnType, UpdateReturnUpdatedType } from "../DynamoService"; | ||
import { KeySchema, TableSchema } from "../KeySchema"; | ||
@@ -47,2 +47,3 @@ import { ValidationError } from "../ValidationError"; | ||
query(params: QueryParams, projection: string[]): Promise<QueryResult<Partial<T>>>; | ||
count(params: QueryCountParams): Promise<QueryCountResult>; | ||
scan(params: ScanParams): Promise<ScanResult<T>>; | ||
@@ -49,0 +50,0 @@ scan<P extends keyof T>(params: ScanParams, projection: P | P[]): Promise<ScanResult<Pick<T, P>>>; |
@@ -65,2 +65,5 @@ "use strict"; | ||
} | ||
count(params) { | ||
return this.db.count(this.tableName, params); | ||
} | ||
scan(params, projection) { | ||
@@ -67,0 +70,0 @@ const realProjection = (projection || this.knownKeys); |
{ | ||
"name": "@xapp/dynamo-service", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
510426
10660