05-scan-test.js - Amazon DynamoDB

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

05-scan-test.js

Program 05-scan-test.js melakukan operasi Scan di TryDaxTable.

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 daxClient = null; if (process.argv.length > 2) { var dax = new AmazonDaxClient({ endpoints: [process.argv[2]], region: region, }); daxClient = new AWS.DynamoDB.DocumentClient({ service: dax }); } var client = daxClient != null ? daxClient : ddbClient; var tableName = "TryDaxTable"; var iterations = 5; var params = { TableName: tableName, }; var startTime = new Date().getTime(); for (var i = 0; i < iterations; i++) { client.scan(params, function (err, data) { if (err) { console.error( "Unable to read item. Error JSON:", JSON.stringify(err, null, 2) ); } else { // Scan succeeded } }); } var endTime = new Date().getTime(); console.log( "\tTotal time: ", endTime - startTime, "ms - Avg time: ", (endTime - startTime) / iterations, "ms" );