Skip to content

TractorZoom/serverless-mysql-utils

Repository files navigation

@tractorzoom/serverless-mysql-utils

Wrapper around serverless-mysql implementing standardized error handling and automatic retries

Commitizen friendly jest Prettier Renovate enabled semantic-release

pull_request_verify publish

Available Methods

Method: executeQuery(queryString)
parameter type description
query string sql query string to be executed

How do I use? 🤔

Installation:
npm i @tractorzoom/serverless-mysql-utils
Usage:

The following environment variables must be set or a config object must be passed as a second arg to executeQuery to make the connection with mysql:

variable type description
database string mame of the database to use for this connection
host string the hostname of the database you are connecting to
user string the mysql user to authenticate as
password string the password of that mysql user
import dbConfig from './config';
import { executeQuery } from '@tractorzoom/serverless-mysql-utils';

export const getItems = async () => {
    const queryString = `SELECT * FROM MyTable WHERE id = "some-guid"`;

    const response = await executeQuery(queryString, dbConfig);

    if (response.error) {
        return [];
    }

    return response;
};

About

Automatic retries and standardized error handling for dealing with MySQL in the serverless ecosystem

Resources

Stars

Watchers

Forks

Packages

No packages published