02-write-data.js - Amazon DynamoDB
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

02-write-data.js

The 02-write-data.js program writes test data to TryDaxTable.

/** * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * http://aws.amazon.com/apache2.0/ * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ const AmazonDaxClient = require('amazon-dax-client'); var AWS = require("aws-sdk"); var region = "us-west-2"; AWS.config.update({ region: region }); var ddbClient = new AWS.DynamoDB.DocumentClient() var tableName = "TryDaxTable"; var someData = "X".repeat(1000); var pkmax = 10; var skmax = 10; for (var ipk = 1; ipk <= pkmax; ipk++) { for (var isk = 1; isk <= skmax; isk++) { var params = { TableName: tableName, Item: { "pk": ipk, "sk": isk, "someData": someData } }; // //put item ddbClient.put(params, function(err, data) { if (err) { console.error("Unable to write data: ", JSON.stringify(err, null, 2)); } else { console.log("PutItem succeeded"); } }); } }