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
- ClientConfig
- Connection
- Credentials
- DeleteOptions
- DeleteOutput
- GetOptions
- GetOutput
- GlobalSecondaryIndex
- PutOptions
- PutOutput
- QueryOptions
- QueryOutput
- ScanOptions
- ScanOutput
- StreamConsumerOptions
- StreamRecord
- StreamRecordDynamodb
- 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 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 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 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 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 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 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 |
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 |
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 |
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 |
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 |