1.0.1 • Published 4 years ago

@teleology/rds-api v1.0.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

@teleology/rds-api

A slim wrapper around the AWS-SDK RdsDataService to auto parse incoming and outgoing variables.

Installations

yarn add @teleology/rds-api

Usage

import rds from '@teleology/rds-api';

const rdsConstructorOptons = {
  region: 'us-east-1',
}

// Query function as well as promisified versions of the 
// RDSDataService are returned
const client = rds({
  secretArn: "rdsSecretsArn",
  resourceArn: "rdsArn",
  database: "dbname",
  options: rdsConstructorOptons,
});

(async() => {
  // Single request
  const { records = [] } = await client.query(
    `select * from foo where firstname = :name`, 
    {
      name: 'foo'
    }
  );

  // Batched request
  await client.query(
    `INSERT INTO foo(
      firstname,
      lastname
    )
    VALUES (
      :firstname,
      :lastname
    )`, 
    [
      {
        firstname: 'Bob',
        lastname: 'Cob',
      },
      {
        firstname: 'Sara',
        lastname: 'Clara',
      }
    ]
  );
})();

Changelog

1.0.0

  • Initial package creation
1.0.1

4 years ago

1.0.0

4 years ago