@cn-shell/aws-utils
Version:
A Cloud Native extension for AWS
100 lines (99 loc) • 2.24 kB
TypeScript
import * as Aws from "./aws-base";
import AWS_DDB from "aws-sdk/clients/dynamodb";
export declare let CriteriaOperators: {
EQ: string;
NE: string;
LE: string;
LT: string;
GE: string;
GT: string;
BETWEEN: string;
BEGINS_WITH: string;
EXISTS: string;
NOT_EXISTS: string;
};
export interface Opts extends Aws.Opts {
table: string;
tableIndex?: string;
partitionKey: string;
sortKey?: string;
}
export interface UpdateItemConditions {
condition: string;
attribute: string;
value?: number | string | boolean;
between?: {
high: any;
low: any;
};
}
export interface UpdateItemParams {
key: {
partitionKeyValue: any;
sortKeyValue?: any;
};
set?: {
[key: string]: any;
};
add?: {
[key: string]: any;
};
append?: {
[key: string]: any[];
};
remove?: string[];
conditions?: UpdateItemConditions[];
returnUpdated?: string;
}
export interface SortKeyCriteria {
operator: string;
value?: number | string | boolean;
between?: {
high: any;
low: any;
};
}
export interface QueryParams {
partitionKeyValue: any;
sortCriteria?: SortKeyCriteria;
reverseQuery?: boolean;
limit?: number;
nextKey?: AWS_DDB.DocumentClient.Key;
attributes?: string[];
}
export interface GetDeleteParams {
partitionKeyValue: any;
sortKeyValue?: any;
}
export declare class Table extends Aws.Base {
private documentClient;
private _table;
private _tableIndex?;
private _partitionKey;
private _sortKey?;
constructor(name: string, opts: Opts);
start(): Promise<boolean>;
stop(): Promise<void>;
healthCheck(): Promise<boolean>;
putItem(item: { [key: string]: any }): Promise<boolean>;
putItems(
items: {
[key: string]: any;
}[],
): Promise<boolean>;
getItem(
key: GetDeleteParams,
): Promise<AWS_DDB.DocumentClient.GetItemOutput | void>;
deleteItem(key: GetDeleteParams): Promise<boolean>;
query(query: QueryParams): Promise<AWS_DDB.DocumentClient.QueryOutput>;
updateItem(
item: UpdateItemParams,
): Promise<
| boolean
| {
[key: string]: any;
}
>;
getNextAtomicCounter(counter: string, counterKey?: string): Promise<string>;
scan(): Promise<AWS_DDB.DocumentClient.ScanOutput>;
}