unstorage icon indicating copy to clipboard operation
unstorage copied to clipboard

feat: add `aws-dynamodb` driver

Open daaru00 opened this issue 1 year ago • 6 comments

Add support for Amazon DynamoDB. Also add support for DynamoDB Time to Live (TTL), this is order to manage key expiration.

A note about "aws-dynamodb" driver's tests: they will fail if no valid AWS credentials will be found (using profile or environment variables).

daaru00 avatar May 25 '23 17:05 daaru00

Live Preview ready!

Name Edit Preview Latest Commit
unstorage Edit on Studio ↗︎ View Live Preview b10053737594a45701e8de6170a223ae9c797aa8

nuxt-studio[bot] avatar May 25 '23 17:05 nuxt-studio[bot]

Thanks for the PR @daaru00. Checking locally, the types and test are failing. Can you please check? 🙏🏼

pi0 avatar Aug 07 '23 20:08 pi0

Hello @pi0,

May I ask what error message you get? I suspect it's something related to AWS credentials, without them the integration tests will fail not being able to access a valid AWS account (in order to create a temporary table to run tests on).

daaru00 avatar Aug 09 '23 12:08 daaru00

I suspect it's something related to AWS credentials, without them the integration tests will fail not being able to access a valid AWS account (in order to create a temporary table to run tests on).

Do you think we can mock AWS library to make sure tests run locally?

pi0 avatar Aug 09 '23 14:08 pi0

@pi0 I did a test using the official mock library managed by AWS: https://aws.amazon.com/it/blogs/developer/mocking-modular-aws-sdk-for-javascript-v3-in-unit-tests/. Actually I replaced the api calls using Map saving key and value in-memory:

client
    .on(GetCommand)
    .callsFake(input => {
      const key = input.Key.key
      if (!data.has(key)) {
        return { Item: undefined }
      }
      return { Item: { key, value: data.get(key) } }
    })
    .on(ScanCommand)
    .callsFake(() => {
      return { Items: Array.from(data.entries()).map(([ key, value ]) => ({ key, value })) }
    })
    .on(PutCommand)
    .callsFake(input => {
      data.set(input.Item.key, input.Item.value)
    })
    .on(DeleteCommand)
    .callsFake(input => {
      data.delete(input.Key.key)
    })

Is this the expected result?

ps: I also had to update the AWS SDK due to some internal conflicts with typescript types

daaru00 avatar Aug 28 '23 08:08 daaru00

what is the timeline for this to be merged into master?

aheissenberger avatar Jan 28 '24 23:01 aheissenberger