As a developer, i don't want to connect all the time to Amazon web services, and I installed DynamoDB in my local puter referring the AWS Docs. I am using node.js in the backend.
I am using dynamoose as the modeling tool for Amazon's DynamoDB in my production, How can I use the same dynamoose for querying my local DynamoDB tables for development?
As a developer, i don't want to connect all the time to Amazon web services, and I installed DynamoDB in my local puter referring the AWS Docs. I am using node.js in the backend.
I am using dynamoose as the modeling tool for Amazon's DynamoDB in my production, How can I use the same dynamoose for querying my local DynamoDB tables for development?
Share Improve this question edited Jan 12, 2018 at 17:13 Charlie Fish 20.6k23 gold badges106 silver badges198 bronze badges asked Jan 12, 2018 at 10:17 SabreenaSabreena 6492 gold badges13 silver badges25 bronze badges4 Answers
Reset to default 2You just use this in your code:
dynamoose.local();
Assuming you have a properties file in your application, you probably want a property flag to indicate whether you are in Development or Production. Then in your code, get the property, if you are in Development, run the dynamoose.local() line.
EDIT: I don't code in javascript but it will be something like:
const { NODE_ENV } = process.env
if (NODE_ENV == "DEV") {
dynamoose.local();
}
This assume you have a properties file in your application where you set a system property called "environment" to have a value of say "DEV" or "PROD".
There may be a version thing, but I had to do
var dynamoose = require('dynamoose');
dynamoose.aws.ddb.local();
If you are looking for newer versions of dynamoose the correct syntax is.
dynamoose.aws.ddb.local(http://localhost:8000)
https://dynamoosejs./guide/Dynamoose/#dynamooseawsddblocalendpoint
The code below should allow you to setup Dynamoose for use locally.
var dynamoose = require('dynamoose');
dynamoose.local('http://localhost:8000');
This assumes DynamoDB is running locally on port 8000. If you are not running DynamoDB Local on port 8000 you will have to update the second line above to reflect the correct port.
Edit
As mentioned in the ments you don't need to specify 'http://localhost:8000'
as those are the defaults. You can of course change the port or host to be what you want if you are not using the default options of port being 8000 and host being localhost.