Skip to content

Instantly share code, notes, and snippets.

@lkptrzk
Created December 5, 2014 00:10
Show Gist options
  • Save lkptrzk/902fe6f1ba98cc54ff87 to your computer and use it in GitHub Desktop.
Save lkptrzk/902fe6f1ba98cc54ff87 to your computer and use it in GitHub Desktop.
var Aws = require('aws-sdk');
var DynamoClient = require('dynamodb-doc').DynamoDB;
// This script uses the Shared Credentials File. See reference below for more:
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
Aws.config.update({ region: 'us-east-1' });
var internals = {};
internals.dynamoClient = new DynamoClient();
internals.writeToDynamo = function () {
var params = {
TableName: 'test',
};
params.Item = {
ts: Number(Date.now()),
name: 'test',
};
internals.dynamoClient.putItem(params, function (err, data) {
if (err) {
console.error(err);
console.error(err.stack);
}
else {
console.log(data);
}
});
};
internals.dynamoClient.scan({ TableName: 'test' }, function (err, result) {
if (err) {
throw err;
}
console.log(result);
setInterval(internals.writeToDynamo, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment