chasent / knex-data-api-client

Knex Aurora Data API Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

knex-aurora-data-api-client

Knex Aurora Data API Client

npm npm

This is a fork of the knex-data-api-client by @alan-cooney to support both Postgres and Mysql

The Knex Aurora Data API Client is a Knex extension that supports the RDS Data API, built using Jeremy Daily's excellent data-api-client module.

Support for transactions, and nestTables is included.

Configuration

The library uses the default AWS credentials to connect to the RDS database using the data-api. The data-api-client that this library is a using provides more documentation on the permissions required and how to enable the data-api for the database.

Use

To use aurora in mysql mode:

const knexDataApiClient = require('knex-aurora-data-api-client');
const knex = require('knex')({
  client: knexDataApiClient.mysql,
  connection: {
    secretArn: 'secret-arn', // Required
    resourceArn: 'db-resource-arn', // Required
    database: 'db-name',
    region: 'eu-west-2',
  },
});

To use aurora in postgres mode:

const knexDataApiClient = require('knex-aurora-data-api-client');
const knex = require('knex')({
  client: knexDataApiClient.postgres,
  connection: {
    secretArn: 'secret-arn', // Required
    resourceArn: 'db-resource-arn', // Required
    database: 'db-name',
    region: 'eu-west-2',
  },
});

Nested tables support

Note - this significantly increases the data required back from the RDS data api.

knex().doSomething().options({ nestTables: true });

Credits

Forked from Skyhook knex-data-api-client and provided under an MIT license.

About

Knex Aurora Data API Client

License:MIT License


Languages

Language:JavaScript 100.0%