Skip to content

Files

Latest commit

23107e7 · Jan 7, 2025

History

History

dynamodb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 23, 2024
Mar 19, 2024
Sep 23, 2024
Mar 19, 2024
Apr 22, 2024
Sep 23, 2024
Sep 23, 2024
Aug 1, 2024
Aug 1, 2024
Sep 23, 2024
Sep 30, 2024
Sep 23, 2024
Jan 7, 2025
Jan 7, 2025
Jul 1, 2024

README.md

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.