3

As a developer, i don't want to connect all the time to Amazon web services, and I installed DynamoDB in my local computer 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?

4 Answers 4

2

You 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".

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Stu, Could you please put some example here!
There you go. Setting the system property in the first place will depend on your deployment environment.
If I have more than one table, how to connect to a particular table?
You don't connect to table. You specify it in your request.
2

There may be a version thing, but I had to do

var dynamoose = require('dynamoose');
dynamoose.aws.ddb.local();

Comments

2

If you are looking for newer versions of dynamoose the correct syntax is.

dynamoose.aws.ddb.local(http://localhost:8000)

https://dynamoosejs.com/guide/Dynamoose/#dynamooseawsddblocalendpoint

Comments

1

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 comments 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.

1 Comment

this will work but you don't actually need to specify the address or port if just running with localhost and 8000 as these are the defautls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.