amazon-dynamodbdynamoose

Why does dynamoose store the data only for a very short time?


I use simple setup from dynamoose page.

const startUpAndReturnDynamo = async () => {
  const dynaliteServer = dynalite();
  await dynaliteServer.listen(8000);
  return dynaliteServer;
};

const createDynamooseInstance = () => {
    dynamoose.AWS.config.update({
      accessKeyId: 'AKID',
      secretAccessKey: 'SECRET',
      region: 'us-east-1'
    });
    dynamoose.local(); // This defaults to "http://localhost:8000"
}

const bootStrap = async () => {
    await startUpAndReturnDynamo();
    createDynamooseInstance();
}

bootStrap();

I can save the data, get the data by Model.get(hashKey) and my data seems likely be saved only for less than a minute? After that query returns undefined.

There is another TTL (time to live) setup but since I didn't use it. My data should stay permanent in DynamoDB, right?


Solution

  • I found the problem.

    Because I was using the remoting dynamodb, not the local one.

    dynamoose.local() should be changed to dynamoose.ddb()
    

    dynamoose.local() Configure Dynamoose to use a local DynamoDB

    dynamoose.ddb() Configures and returns the AWS.DynamoDB object.

    The document of dynamoosejs is very detailed but somehow not easily comprehensible to me. I posted the answer in case newbie with dynamoose facing the same problem.