Click a module name below to see its documentation
- Transactional
- Transactional.DBHManager
- Transactional.IBus
- Transactional.IDBH
- Transactional.IStatement
- Transactional.LogDBH
- Transactional.MySQLDBH
- Transactional.MySQLStatement
- Transactional.PooledDBH
- Transactional.RecordMapper
- Transactional.Transaction
Written On: 6/20/2017
The transactional library provides a mechanism for performing database transactions on an RDBMS from a node.js application.
This library only implements a driver for MySQL right now, but other drivers can be registered by calling the register function. Drivers are responsible for adapting to the interface used by this library.
Uses the registered database driver creation function to create a database manager. An optional logger can be specified.
Store references to driver creation functions
Registers a database driver to be used to create a database manager at a later time.
Written On: 6/20/2017
Provides methods to manage a set of connections to a database, including creating connections, retrieving a connection from a pool, and performing an atomic transaction with a connection retrieved from the pool.
Does not provide pooling capabilities on its own. It instead relies on provided functions to interact with the pool. May provide a default pool implementation at some point.
Closes the connection pool. After calling this method, the object should no longer be used.
Creates a new connection that is not from the connection pool. A promise for the connection is returned. You are responsible for closing the connection.
Wraps a connection in a record mapper.
Wraps a connection in a pooled connection, then wraps that in a record mapper to provide additional functionality.
Returns a promise for a connection from the connection pool. The connection is already open.
Constructs a new DBHManager with the provided functions to create connections, get connections from a connection pool, and to return connections to the pool, and shutdown the pool.
createLogger (possibly) wraps a connection in a logger
The provided functions must take and return IDBH implementations.
toPool is guaranteed to receive the same type of IDBH that fromPool provides.
Convenience method to interpret transactions. The transaction is a Free monad whose values can be of type Async or Transaction.
The transaction is interpreted to an Async. You can use Free.Control primitives as well as Transaction instructions.
For most applications, this should not be used -- instead create and use your own composite interpreter including the transactional interpreter and run the resulting Async at the root of your application.
Written On: 6/20/2017
An interface for publishing to an Event Bus.
Publishes an event of the given type with the given data to the bus. Returns immediately.
Written On: 6/20/2017
An interface to a database handle for a relational database.
Begins a transaction. Returns a promise for the result of beginning the transaction.
Closes the database connection.
Commits the transaction. Returns a promise for the result.
Connects to the database. Returns a promise for the result of the connection.
Prepares a statement to run on the database. Returns a promise for a statement handle. The statement must be disposed of when the connection is closed.
Rolls back the transaction. Returns a promise for when rollingback finishes.
Returns a stream of status events.
The only required functionality is that when the connection is closed (in any possible way), the stream returned by this method is ended.
Written On: 6/20/2017
An interface to a statement handle for a relational database.
Cleans up underlying resources associated with the statement handle.
Executes the prepared statement with the provided placeholder bindings. Returns a promise with the result of the query.
The result type will depend on the type of statement that is executed. If it is a Select Query, then a list of objects, representing the rows selected is returned. If it is an Insert Statement, then the ID of the new row is returned. If it is any other kind of statement, then nothing is returned.
Written On: 6/20/2017
Adds logging to connections, so that the queries ran on them are written to some medium.
Begins a transaction on the base IDBH.
Closes the base connection.
Commits the transaction on the base IDBH
Connects the base IDBH.
Medium that writes to the console.
Medium that writes to a file
Medium that writes to a list
Creates an IDBH that writes to the closed over media.
Returns a function that will wrap a provided connection in a logger that writes to the provided media.
Writes the query, with parameters substituted for arguments, to the media, then executes underlying statement.
Returns a function that will wrap a prepared statement to write to the provided media, with the provided query.
Medium that writes to underlying media
Constructs a new IDBH that writes queries to some media before calling the same methods on the base connection.
The identity function by another name.
Prepares a statement on the base IDBH.
Replaces the parameters of a prepared statement with the binded arguments to execute it with. This is for display purposes only and does not escape the arguments.
Rolls back the transaction on the base IDBH
Returns a stream of status events for both the pooled connection and underlying IDBH.
Written On: 6/20/2017
Adapts node-mysql to use the IDBH interface.
Begins a transaction. Returns a promise for the result of beginning the transaction.
Closes the database connection.
Commits the transaction. Returns a promise for the result.
Connects to the database. Returns a promise for the result of the connection.
Returns functions to manage a pool of MySQLDBH connections.
Wrap the connection
Prepares a statement to run on the database. Returns a promise for a statement handle.
Rolls back the transaction. Returns a promise for when rollingback finishes.
Returns a stream of status events.
Written On: 6/20/2017
A "prepared" statement for node-mysql.
Cleans up underlying resources associated with the statement handle.
Executes the prepared statement with the provided placeholder bindings. Returns a promise with the result of the query.
Maps the result of a query to the correct type per the IDBH contract.
Construct a new MySQLStatement.
Written On: 6/20/2017
Wraps an underlying dbh that is pooled so closing it returns it to the connection pool.
Attempting to use the pooled connection after it is closed will cause each method to return an error.
Begins a transaction on the base IDBH.
Closes the pooled connection. This will cause the underlying IDBH to be returned to its pool.
Commits the transaction on the base IDBH
Connects the base IDBH.
Constructs a Pooled DBH connection from an underlying dbh.
Prepares a statement on the base IDBH.
Rolls back the transaction on the base IDBH
Returns a stream of status events for both the pooled connection and underlying IDBH.
Written On: 6/20/2017
Extends the IDBH interface to include record mapping.
Begins a transaction on the base IDBH.
Closes the base connection.
Commits the transaction on the base IDBH
Connects the base IDBH.
Deletes the record from the table. Returns a promise for the result of the deletion.
Inserts a record into a table. Returns a promise with the result of the insertion.
Extends the underlying IDBH with additional functionality.
Splits an object into lists of its keys and values.
Prepares a statement on the base IDBH.
Runs a sql query on the database, preparing a statement, bindings the bindings to placeholders, and executing it. Returns a promise for the result.
Useful when you only want to execute a statement once.
Reads a record from the table. Returns a promise for the row read from the table.
Rolls back the transaction on the base IDBH
Returns a stream of status events from the base IDBH.
Updates the record in the table. Returns a promise with the result of the update.
Written On: 6/20/2017
Provides a DSL to compose and execute database transactions. This comes in the form of a Free monad over a (rather large) functor defined below, along with an interpreter that translates monadic values into calls in the library.
This is the preferred way to use this library and produces much cleaner code than directly using the library functions to interact with your database.
Delete a row in a table.
Emit an event. This is used to signal that an event occurred while executing the transaction. The interpreter will automatically publish these events to a provided event bus.
Execute a prepared statement on the database.
Insert a row into a table.
Creates an interpreter constructor that can be used with ConcurrentFree.interpret.
This interprets to Async and runs queries/statements in a transaction.
Lift a normal value into the Transaction context.
Prepare a statement for execution on the database.
Execute a query on the database.
Read a row from a table.
Update a row in a table.