unstorage
unstorage copied to clipboard
feat: add `aws-dynamodb` driver
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).
Live Preview ready!
Name | Edit | Preview | Latest Commit |
---|---|---|---|
unstorage | Edit on Studio ↗︎ | View Live Preview | b10053737594a45701e8de6170a223ae9c797aa8 |
Thanks for the PR @daaru00. Checking locally, the types and test are failing. Can you please check? 🙏🏼
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).
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 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
what is the timeline for this to be merged into master?