mysql-invoker

0.0.3 • Public • Published

Mysql Invoker

Still in Development

Introduction
Installation
Getting Started
MIT License


Introduction

This module enables you to invoke stored procedure and function that was defined explicitly in your mysql database. At runtime mysql invoker will automatically format the arguments for your stored procedure and function using the object that was pass to it.

Installation

This is done using (NPM) node package manager just copy and past in your terminal and npm will manage the rest.

npm i mysql-invoker --save

Getting Started

To get started with the module, after installation just import the module and then use the destructuring construct to access the implementated class.

import { MysqlInvoker } from 'mysql-invoker';

The Invoker instance

Create a new instance of mysql invoker and pass at least the minimum required configuration options as object, see config options for more information

const mysql = new MysqlInvoker( { /** Config Options **/ } );

Basic Connection Configuration options

Each instance will require a set of configuration options, these options will use when connecting to the database.

Properties Type Required Description
host string Yes The host name of the database
user string Yes The user name used by the user
database string Yes The database to establish connection to
password string Yes The password used by the user
multipleStatements boolean Optional Allow for multiple statement to be excecute. Visit mysql github page for more information

Invoking a stored procedure

When invoking a stored procedure or function you need to first create the argument object model. This model will contain all the arguments needed to carry out the excecution process.

Create the store procedure argument model

const createUserArg: any = {
 
    name: 'Wycliffe Peart'
}

Please note that the order of the arguments in the model must match the order of the stored procedure and function argument list.

 
async function createUser(createUserArg: object): Promise<any[]>{
 
    const mysql = new MysqlInvoker( { /** Config Options **/ } );
 
    return await mysql.invokeProcedure<any[]>('createUser', createUserArg);
}

MIT License

Copyright (c) 2018 Wycliffe Peart

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Package Sidebar

Install

npm i mysql-invoker

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

39.8 kB

Total Files

22

Last publish

Collaborators

  • wycliffe-peart