AWS SDK for JavaScript DynamoDB 模块提供了与 Amazon DynamoDB 进行交互的接口。使用此模块,您可以轻松地在您的JavaScript应用程序中创建、读取、更新和删除DynamoDB表中的数据。

主要功能

  • 数据操作:支持CRUD(创建、读取、更新、删除)操作。
  • 查询和扫描:支持复杂的查询和扫描操作。
  • 数据模型:支持DynamoDB数据模型,如键、属性、索引等。
  • 性能优化:支持分页、批处理等性能优化技术。

快速开始

以下是一个简单的示例,展示了如何使用 AWS SDK for JavaScript DynamoDB 创建一个表:

const AWS = require('aws-sdk');
const dynamodb = new AWS.DynamoDB.DocumentClient();

const params = {
  TableName: 'MyTable',
  KeySchema: [
    { AttributeName: 'PartitionKey', KeyType: 'HASH' },
    { AttributeName: 'SortKey', KeyType: 'RANGE' }
  ],
  AttributeDefinitions: [
    { AttributeName: 'PartitionKey', AttributeType: 'S' },
    { AttributeName: 'SortKey', AttributeType: 'S' }
  ],
  ProvisionedThroughput: {
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5
  }
};

dynamodb.createTable(params, function(err, data) {
  if (err) {
    console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
  } else {
    console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
  }
});

相关文档

如果您想了解更多关于 AWS SDK for JavaScript DynamoDB 的信息,请访问以下链接:

DynamoDB 图标