Registry / database / phantasy-mysql

phantasy-mysql

JSON →
library1.1.2jsnpmunverified

A minimal MySQL effect library for the Phantasy functional programming library. Version 1.1.2 is current and stable, but the package has seen no recent releases and depends on the deprecated phantasy package. It provides EffTask-based wrappers around mysql2 for connection pooling, single connections, and queries. It is designed for use with phantasy's Eff monad and is not intended for general use outside that ecosystem.

npm install phantasy-mysql
INSTALL
IMPORT
SIG · PHANTASY-MYSQL
P
phantasy-mysql
databasejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createPool
import { createPool } from 'phantasy-mysql'
const { createPool } = require('phantasy-mysql')
ESM-only; no CommonJS support.
query
import { query } from 'phantasy-mysql'
import query from 'phantasy-mysql'
query is a named export, not default.
DbPool
import { DbPool } from 'phantasy-mysql'
Type import for TypeScript users; DbPool is a type alias.

Creates a connection pool, obtains a connection, and runs a simple SELECT query.

import { createPool, getConnection, query } from 'phantasy-mysql' import { runEff } from 'phantasy' const poolOpts = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: 'test', connectionLimit: 10 } const app = createPool(poolOpts) .chain(pool => getConnection(pool)) .chain(conn => query('SELECT 1 AS result', [], conn)) runEff(app).fork( console.error, (result) => console.log('Query result:', result) )
Debug
Known issues
deprecatedThe entire phantasy ecosystem is deprecated in favor of fp-ts or similar libraries.
fix
Migrate to fp-ts and a MySQL library like mysql2 directly.
affects: >=0.0.0
gotchaquery expects an array of parameters (even empty) as second argument; omitting it causes runtime error.
fix
Always provide an array as second argument to query, e.g., query('SELECT ?', [1], conn).
affects: >=0.0.0
gotchacreatePool returns an EffTask, not a pool directly; you must run it via runEff or similar.
fix
Use runEff from phantasy to execute the EffTask and obtain the pool.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'createPool' of 'require(...)' as it is undefined.
Trying to use CommonJS require on an ESM-only package.
fix
Use ES module import syntax: import { createPool } from 'phantasy-mysql'
Error: PoolOpts must have a host property
Missing required 'host' field in PoolOpts object.
fix
Ensure PoolOpts includes host (string) and database (string) as required fields.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
phantasyrequiredCore dependency for EffTask monad and types
mysql2requiredMySQL driver library
Agent activity
4 hits · last 30 days
node
4
Resources
phantasy-mysql — npm install phantasy-mysql · libregistry