Typescript ORM of DynamoDB, written from scratch to fully support DynamoDB. Powering Vingle
- Serialize / Deserialize DynamoDB record -> TS class object based on annotations.
- Table Configurations
- Create secondary indexes (Both local / global)
- Configure TTL
- FullPrimaryKey (Hash, Range)
- HashPrimaryKey (Hash)
- Local, both hash and range key
- Global, both hash and range key
- Type Support (Number / String / Boolean / Array / Object / Buffer)
- DAX Support
- Optimized aws-sdk usage
- aws-sdk has a serious problem of not reusing HTTP connection towards DynamoDB by default. check this issue this could cause unbearable latency sometimes with showing > 100ms. this is more of an issue of NodeJS HTTP module but nevertheless, this is optimized as a default. Code
- AWS X-Ray support
- X-Ray is serverless distributed tracing service. In order to log DynamoDB transaction into it, you also need to some sort of risk monkey-patching. Here you can turn it on by setting
process.env.ENABLE_XRAY = "true"
- You can change the endpoint of DynamoDB by setting the environment variable or setting new connection, So you can install local-dynamo locally at setup endpoint to local. refer package.json for the detailed how-to
Also, dynamo-types let you overcome several limits that DynamoDB or the aws-sdk has.
- BatchWrite (batchDelete / batchPut) has a limit of a maximum of 25 items per request.
- dynamo-typeorm automatically splits given items into chunks of 25 and sends requests in parallel
- BatchGet has a limit of a maximum of 100 items per requests
- dynamo-typeorm automatically splits given keys to chunks of 100 and sends requests in parallel
- BatchGet doesn't keep the order of items as it is in input keys,
- dynamo-typeorm sort return items based on input keys
- BatchGet doesn't handle "missing items".
- dynamo-typeorm has "BatchGet" / "BatchGetFull"
order items follow to keys, missing items are just missing. return type Promise<Array>
so keys.legnth !== items.keys in this case
order items follow to keys, fill missing items with "null". return type Promise<Array<Item | null>>
so keys.length === items.keys always true
And most importantly, all of those queries regardless of whether it's from index or primary key, strongly typed. I mean what's the point of using typescript if not anyway?
card.id = 100;
card.title = "Title";
await Card.primaryKey.get100, "Title";
DynamoDB supports 2 different kinds of connections. Plain connections to DynamoDB through HTTP, or through DAX.
dynamo-typeorm supports this by letting you create a separate connection for each table.
Then any query that is sent to the Card table will be sent through DAXConnection.
If you don't specify any connection, it automatically uses default connection, which is DynamoDBConnection.