Skip to content

Commit 9673a60

Browse files
committed
v1.0.1 - docs increase, index include
1 parent 6cbc8f4 commit 9673a60

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# AWS Aurora Data API Client
22

3+
<p>
4+
<img alt="npm" src="https://img.shields.io/npm/dw/rds-data?style=flat-square">
5+
<img alt="NPM" src="https://img.shields.io/npm/l/rds-data?style=flat-square">
6+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square">
7+
</p>
8+
39
A decorator for the AWS Data API for Aurora Serverless. It decorates and abstracts the Amazon SDK's implementation to make it feel more like a traditional MySQL wrapper than an HTTP based web service. It is written in Typescript and provides type-aware return objects which allows for better support in Typescript-based solutions.
410

511
## Installation
@@ -65,6 +71,40 @@ await rds.transaction().then(async (transactionId) => {
6571
await rds.rollback(transactionId);
6672
```
6773

74+
## Typed Results
75+
76+
When a response comes back from the decorator it is stored in specific typed results. Here is an example of pulling a **date**, a **string** and a **number**
77+
78+
```js
79+
const db = new RDSDatabase(params).getInstance();
80+
const results = db.query( "SELECT born, name, age FROM Names WHERE name = :name", { name: "Scarlett Johansson" });
81+
82+
for(const result of results.data) {
83+
const born = result.date; // Date() instance === 1984-11-22
84+
const name = result.string; // string instance === "Scarlett Johansson"
85+
const age = result.number; // integer primitive === 35
86+
}
87+
```
88+
89+
## Types
90+
91+
When a response comes in the RDSData returns it already typed for you. Depending on the column type it also may coerce or represent the value in another "type."
92+
93+
Results are managed from the following database types into result types:
94+
95+
| Database Type | RDSData Type | Description |
96+
| ------------- | ------------ | ----------- |
97+
| BINARY | *row*.buffer | converts the blob value into a new Buffer |
98+
| BINARY | *row*.string | converts the binary value into a string |
99+
| BIT | *row*.boolean | converts the bit into boolean |
100+
| BIT | *row*.number | converts the bit to either a 1 or a 0 |
101+
| TIMESTAMP, DATETIME and DATE | *row*.date | a parsed instance of `new Date()` |
102+
| TIMESTAMP, DATETIME and DATE | *row*.string | the string value of the date/time ISO8601 |
103+
| TIMESTAMP, DATETIME and DATE | *row*.number | timestamp value of the column |
104+
| INT, INT UNSIGNED, BIGINT, BIGINT UNSIGNED | *row*.number | numeric value |
105+
| TEXT, CHAR, VARCHAR | *row*.string | string value |
106+
107+
68108
## Overview
69109
Amazon AWS produces a Data API for Aurora Serverless which is a great API if you are building serverless solutions. One of the consistent challenges with serverless lambda in a VPC has extended cold start times and does not have access to the outside world unless you stand up a NAT Gateway. Thus, inside the VPC you can see your Aurora instances but you cannot see the outside world. The API provides a nice way to exist in the traditional lambda pool but still access your private LAN Aurora instance. The API also helps with connection pooling and other challenges with building serverless applications that may end up with aggressive concurrency.
70110

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "rds-data",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A decorator for the AWS Data API for Aurora Serverless. It decorates and abstracts the Amazon SDK's implementation to make it feel more like a traditional MySQL wrapper than an HTTP based web service. It is written in Typescript and provides type-aware return objects which allows for better support in Typescript-based solutions.",
5-
"main": "RDSData.ts",
5+
"main": "index.ts",
66
"types": "lib/index.d.ts",
77
"scripts": {
88
"test": "jest --config jestconfig.json",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { RDSData } from "./RDSData";
2+
export { default as RDSDatabase } from "./RDSDatabase";

0 commit comments

Comments
 (0)