UNPKG

phantasy-mysql

Version:
107 lines (71 loc) 2 kB
# phantasy-mysql [![Build Status](https://travis-ci.org/tkuminecz/phantasy-mysql.svg?branch=master)](https://travis-ci.org/tkuminecz/phantasy-mysql) [![Coverage Status](https://coveralls.io/repos/github/tkuminecz/phantasy-mysql/badge.svg?branch=master)](https://coveralls.io/github/tkuminecz/phantasy-mysql?branch=master) MySQL Effects ## API ### `createPool` ``` :: PoolOpts -> EffTask {} DbPool Error ``` Returns an `EffTask` that succeeds with a new `DbPool` or fails with an `Error`. ### `getConnection` ``` :: DbPool -> EffTask {} DbConnection Error ``` Returns an `EffTask` that succeeds with a `DbConnection` from the given `DbPool` or fails with an `Error`. ### `createConnection` ``` :: ConnectionOpts -> EffTask {} DbConnection Error ``` Returns an `EffTask` that succeeds with a new `DbConnection` or fails with an `Error`. ### `query` ``` :: string -> Array mixed -> DbConnection -> EffTask {} QueryResult Error ``` Returns an `EffTask` that succeeds with the `QueryResult` or fails with an `Error`. ## Types ### `PoolOpts` ```javascript { host: string, port?: number, user?: string, password?: string, database: string, connectionLimit: number } ``` Options when creating a `DbPool`. ### `ConnectionOpts` ```javascript { host: string, port?: number, user?: string, password?: string, database: string } ``` Options when creating a `DbConnection`. ### `DbPool` Represents a pool of database connections. ### `DbConnection` Represents a single database connection. ### `QueryResult` ```javascript ResultInfo | Array ResultRow ``` The result of a query. It is either a `ResultInfo` object or an array of `ResultRow` objects. ### `ResultInfo` ```javascript { affectedRows: number } ``` The result of a query that does not return results. ### `ResultRow` ```javascript { [k: string]: number | string } ``` A single row in the result set of a query. It is an object with `string` keys and values that are type of either `number` or `string`.