Using DYNAMO DB LOCAL to Node project
To install DynamoDB locally on Windows 7
DynamoDB Local supports the Java Runtime Engine (JRE) version 6.x or newer;
it will not run on older JRE versions.You can download using following link.
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
Go to following link to download dynamo db jar file:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html
Once you have downloaded the archive to your computer, extract the contents and
copy the extracted directory to C:\ drive.
Open a command prompt window, navigate to the downloaded directory where you will find DynamoDBLocal.jar, and enter the following command:
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
or
java -Djava.library.path=. -jar DynamoDBLocal.jar
Now we’re ready to use our local DynamoDB
2013-09-29 12:11:38.530:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT<br/>2013-09-29 12:11:38.618:INFO:oejs.AbstractConnector:Started <br/>
SelectChannelConnector@0.0.0.0:8000
JavaScript Shell for DynamoDB Local
The JavaScript Shell for DynamoDB Local can help jump-start your usage of DynamoDB, all within an interactive, hands-on environment. The JavaScript Shell is bundled with DynamoDB Local, and provides an easy-to-use environment for prototyping and application development.
- Its supports latest version of DynamoDB Local, to run it on your computer while you up and running the Dynamo DB Local server open a web browser on your computer and go to the following URL:http://localhost:8000/shell
Install asw-sdk for node
The preferred way to install the AWS SDK for Node.js is to use the npm package manager for Node.js. Simply open the cmd window inside project folder and type the following
npm install aws-sdk
You can also use Bower to install the SDK by typing the following into a terminal window
bower install aws-sdk-js
Create a js file and define configuration
var AWS = require('aws-sdk');
For work with Local DynamoDB define endpoint will be "http://localhost:8000"
var databaseConfig = {"endpoint": new AWS.Endpoint("http://localhost:8000")};
var dynamoDB = new AWS.DynamoDB(databaseConfig);
To Connect with Local DynamoDB, we need provide dummy entries for required fields(accessKey, Secret and Region).
var dynamoDBConfiguration = {
"accessKeyId": "xxxxxxxxxxxxx",
"secretAccessKey": "xxxxxxxxxxxxxxxxx",
"region": "eu-west-1"
};
Later on to Connect with AWS DynamoDB Service place actual accessKey, Secret and Region.
provide your configurations.
AWS.config.update(dynamoDBConfiguration);
Now you can start use it locally.
No comments:
Post a Comment