Amazon DynamoDB
Prerequisites
Installation
npm i @winglibs/dynamodb
Usage
bring dynamodb;
let table = new dynamodb.Table(
attributes: [
{
name: "id",
type: "S",
},
],
hashKey: "id",
);
// Streams.
table.setStreamConsumer(inflight (record) => {
log("record processed = {Json.stringify(record)}");
});
// Put and query.
test "put and query" {
table.put(
Item: {
id: "1",
body: "hello",
},
);
let response = table.query(
KeyConditionExpression: "id = :id",
ExpressionAttributeValues: {":id": "1"},
);
assert(response.Count == 1);
assert(response.Items[0]["id"].asStr() == "1");
assert(response.Items[0]["body"].asStr() == "hello");
}
In case you want to instantiate your own DynamoDB SDK, you can get the connection details like this:
table.connection.clientConfig.endpoint;
table.connection.clientConfig.credentials;
table.connection.clientConfig.region;
table.connection.tableName;
So you can use the AWS SDK DynamoDB client like this:
new DynamoDB(table.connection.clientConfig);
License
This library is licensed under the MIT License.
API Reference
Table of Contents
- Classes
- Interfaces
- Structs
- AttributeDefinition
- BatchGetOptions
- BatchGetOutput
- BatchWriteOptions
- BatchWriteOutput
- ClientConfig
- Connection
- Credentials
- DeleteOptions
- DeleteOutput
- DeleteRequest
- GetOptions
- GetOutput
- GlobalSecondaryIndex
- PutOptions
- PutOutput
- PutRequest
- QueryOptions
- QueryOutput
- ScanOptions
- ScanOutput
- StreamConsumerOptions
- StreamRecord
- StreamRecordDynamodb
- TableBatchGetOptions
- TableBatchWriteOptions
- TableProps
- TransactWriteItem
- TransactWriteItemConditionCheck
- TransactWriteItemDelete
- TransactWriteItemPut
- TransactWriteItemUpdate
- TransactWriteOptions
- TransactWriteOutput
- UpdateOptions
- UpdateOutput
- ClientProps
- Enums
Table (preflight class)
No description
Constructor
new(props: TableProps): Table
Properties
Name | Type | Description |
---|---|---|
connection | Connection | No description |
tableName | str | No description |
Methods
Signature | Description |
---|---|
inflight batchGet(options: TableBatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: TableBatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight readWriteConnection(): Connection | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
setStreamConsumer(handler: inflight (StreamRecord): void, opts: StreamConsumerOptions?): void | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
Table_tfaws (preflight class)
No description
Constructor
new(props: TableProps): Table_tfaws
Properties
Name | Type | Description |
---|---|---|
connection | Connection | No description |
tableName | str | No description |
Methods
Signature | Description |
---|---|
inflight batchGet(options: TableBatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: TableBatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight readWriteConnection(): Connection | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
setStreamConsumer(handler: inflight (StreamRecord): void, options: StreamConsumerOptions?): void | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
Table_sim (preflight class)
No description
Constructor
new(props: TableProps): Table_sim
Properties
Name | Type | Description |
---|---|---|
connection | Connection | No description |
tableName | str | No description |
Methods
Signature | Description |
---|---|
inflight batchGet(options: TableBatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: TableBatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight readWriteConnection(): Connection | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
setStreamConsumer(handler: inflight (StreamRecord): void, options: StreamConsumerOptions?): void | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
Client (inflight class)
No description
Constructor
new(): Client
Properties
No properties
Methods
Signature | Description |
---|---|
inflight batchGet(options: BatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: BatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
IClient (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight batchGet(options: BatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: BatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
IDynamoResource (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
ITable (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight batchGet(options: TableBatchGetOptions): BatchGetOutput | No description |
inflight batchWrite(options: TableBatchWriteOptions): BatchWriteOutput | No description |
inflight delete(options: DeleteOptions): DeleteOutput | No description |
inflight get(options: GetOptions): GetOutput | No description |
inflight put(options: PutOptions): PutOutput | No description |
inflight query(options: QueryOptions): QueryOutput | No description |
inflight readWriteConnection(): Connection | No description |
inflight scan(options: ScanOptions?): ScanOutput | No description |
setStreamConsumer(handler: inflight (StreamRecord): void, options: StreamConsumerOptions?): void | No description |
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput | No description |
inflight update(options: UpdateOptions): UpdateOutput | No description |
AttributeDefinition (struct)
No description
Properties
Name | Type | Description |
---|---|---|
name | str | No description |
type | str | No description |
BatchGetOptions (struct)
Input to the batchGet
operation on a Client.
Properties
Name | Type | Description |
---|---|---|
RequestItems |
| No description |
ReturnConsumedCapacity | str? | No description |
BatchGetOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsumedCapacity |
| No description |
Responses |
| No description |
UnprocessedKeys |
| No description |
BatchWriteOptions (struct)
Input to the batchWrite
operation on a Client.
Properties
Name | Type | Description |
---|---|---|
RequestItems |
| No description |
ReturnConsumedCapacity | str? | No description |
ReturnItemCollectionMetrics | str? | No description |
BatchWriteOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsumedCapacity |
| No description |
ItemCollectionMetrics | Json? | No description |
UnprocessedItems |
| No description |
ClientConfig (struct)
No description
Properties
Name | Type | Description |
---|---|---|
credentials | Credentials | No description |
endpoint | str | No description |
region | str | No description |
Connection (struct)
No description
Properties
Name | Type | Description |
---|---|---|
clientConfig | ClientConfig? | No description |
tableName | str | No description |
Credentials (struct)
No description
Properties
Name | Type | Description |
---|---|---|
accessKeyId | str | No description |
secretAccessKey | str | No description |
DeleteOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ReturnValues | str? | No description |
DeleteOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
Attributes | Json? | No description |
DeleteRequest (struct)
Represents a request to perform a DeleteItem
operation on an item.
Properties
Name | Type | Description |
---|---|---|
Key | Json | Key is a map of attribute name to attribute values, representing the primary key of the item to delete. All of the table's primary key attributes must be specified |
GetOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsistentRead | bool? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ProjectionExpression | str? | No description |
GetOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
Item | Json? | No description |
GlobalSecondaryIndex (struct)
No description
Properties
Name | Type | Description |
---|---|---|
hashKey | str | No description |
name | str | No description |
nonKeyAttributes |
| No description |
projectionType | str | No description |
rangeKey | str? | No description |
readCapacity | num? | No description |
writeCapacity | num? | No description |
PutOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Item | Json | No description |
ReturnValues | str? | No description |
PutOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
Attributes | Json? | No description |
PutRequest (struct)
Represents a request to perform a PutItem
operation on an item.
Properties
Name | Type | Description |
---|---|---|
Item | Json | A map of attribute name to attribute values, representing the primary key of an item to be processed by PutItem. All of the table's primary key attributes must be specified, and their data types must match those of the table's key schema. If any attributes are present in the item that are part of an index key schema for the table, their types must match the index key schema. |
QueryOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsistentRead | bool? | No description |
ExclusiveStartKey | Json? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
FilterExpression | str? | No description |
IndexName | str? | No description |
KeyConditionExpression | str | No description |
Limit | num? | No description |
ProjectionExpression | str? | No description |
ReturnConsumedCapacity | str? | No description |
ScanIndexForward | bool? | No description |
Select | str? | No description |
QueryOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsumedCapacity | Json? | No description |
Count | num | No description |
Items |
| No description |
LastEvaluatedKey | Json? | No description |
ScannedCount | num | No description |
ScanOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsistentRead | bool? | No description |
ExclusiveStartKey | Json? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
FilterExpression | str? | No description |
IndexName | str? | No description |
Limit | num? | No description |
ProjectionExpression | str? | No description |
ReturnConsumedCapacity | str? | No description |
Segment | num? | No description |
Select | str? | No description |
TotalSegments | num? | No description |
ScanOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConsumedCapacity | Json? | No description |
Count | num | No description |
Items |
| No description |
LastEvaluatedKey | Json? | No description |
ScannedCount | num | No description |
StreamConsumerOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
batchSize | num? | No description |
startingPosition | str? | No description |
StreamRecord (struct)
No description
Properties
Name | Type | Description |
---|---|---|
dynamodb | StreamRecordDynamodb | No description |
eventID | str | No description |
eventName | str | No description |
StreamRecordDynamodb (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ApproximateCreationDateTime | str | No description |
Keys | Json | No description |
NewImage | Json? | No description |
OldImage | Json? | No description |
SequenceNumber | str | No description |
SizeBytes | num | No description |
StreamViewType | str | No description |
TableBatchGetOptions (struct)
TableBatchGetOptions
is used as an input to the batchGet
operation on a Table or Client
(through BatchGetOptions
).
Properties
Name | Type | Description |
---|---|---|
AttributesToGet |
| No description |
ConsistentRead | bool? | No description |
ExpressionAttributeNames |
| No description |
Keys |
| No description |
ProjectionExpression | str? | No description |
ReturnConsumedCapacity | str? | When passed in on a Table resource, ReturnConsumedCapacity will be hoisted to the top level inside of the request. When passed in on a Client resource (via BatchGetOptions ), setting ReturnConsumedCapacity here has no effect, set it inside of the top-level instead. |
TableBatchWriteOptions (struct)
TableBatchWriteOptions
is used as an input to the batchWrite
operation on a Table or Client
(through BatchWriteOptions
).
Properties
Name | Type | Description |
---|---|---|
DeleteRequests |
| DeleteRequests contains a list of DeleteItem operations to perform on this table. |
PutRequests |
| PutRequests contains a list of PutItem operations to perform on this table. |
ReturnConsumedCapacity | str? | When passed in on a Table resource, ReturnConsumedCapacity will be hoisted to the top level inside of the request. When passed in on a Client resource (via BatchWriteOptions ), setting ReturnConsumedCapacity here has no effect, set it inside of the top-level instead. |
ReturnItemCollectionMetrics | str? | When passed in on a Table resource, ReturnItemCollectionMetrics will be hoisted to the top level inside of the request. When passed in on a Client resource (via BatchWriteOptions ), setting ReturnConsumedCapacity here has no effect, set it inside of the top-level instead. |
TableProps (struct)
No description
Properties
Name | Type | Description |
---|---|---|
attributes |
| No description |
billingMode | BillingMode? | Billing mode for the table. Defaults to PAY_PER_REQUEST . |
deletionProtection | bool? | Enables deletion protection for table. Disabled by default. For the Terraform AWS provider, this will also enable lifecycle { prevent_destroy = true } |
globalSecondaryIndex |
| No description |
hashKey | str | No description |
name | str? | No description |
pointInTimeRecovery | bool? | No description |
rangeKey | str? | No description |
timeToLiveAttribute | str? | No description |
TransactWriteItem (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionCheck | TransactWriteItemConditionCheck? | No description |
Delete | TransactWriteItemDelete? | No description |
Put | TransactWriteItemPut? | No description |
Update | TransactWriteItemUpdate? | No description |
TransactWriteItemConditionCheck (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ReturnValuesOnConditionCheckFailure | bool? | No description |
TransactWriteItemDelete (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ReturnValuesOnConditionCheckFailure | bool? | No description |
TransactWriteItemPut (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Item | Json | No description |
ReturnValuesOnConditionCheckFailure | bool? | No description |
TransactWriteItemUpdate (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ReturnValuesOnConditionCheckFailure | bool? | No description |
UpdateExpression | str? | No description |
TransactWriteOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
TransactItems |
| No description |
TransactWriteOutput (struct)
No description
Properties
No properties
UpdateOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Key | Json | No description |
ReturnConsumedCapacity | str? | No description |
ReturnValues | str? | No description |
UpdateExpression | str | No description |
UpdateOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
ConditionExpression | str? | No description |
ExpressionAttributeNames |
| No description |
ExpressionAttributeValues |
| No description |
Item | Json | No description |
ReturnValues | str? | No description |
ClientProps (struct)
No description
Properties
Name | Type | Description |
---|---|---|
credentials | Credentials? | No description |
endpoint | str? | No description |
region | str? | No description |
tableName | str | No description |
BillingMode (enum)
No description
Values
Name | Description |
---|---|
PAY_PER_REQUEST | No description |
PROVISIONED | No description |