javascriptnode.jsamazon-dynamodbdynamoose

How to query local dynamoDB using dynamoose?


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?


Solution

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