FoxHound

raw JSON →
2.0.27 verified Sat Apr 25 auth: no javascript

FoxHound is a fluent query generation DSL for Node.js and the browser (v2.0.27). It generates dialect-specific SQL from a single chainable API, keeping application code database-agnostic while producing parameterized queries for MySQL, PostgreSQL, MSSQL, SQLite, and ALASQL. Key differentiators include schema-aware auto-management of identity columns, timestamps, soft-delete tracking, built-in Fable integration (logging, config, UUID generation), and multiple output dialects including human-readable English and REST URL endpoints. The library supports full CRUD, count, filtering, sorting, joins, pagination, and custom SQL overrides with automatic parameter binding. It is released under the MIT license and follows a configure-then-build pattern.

error TypeError: libFoxHound is not a constructor
cause Attempting to instantiate FoxHound without a Fable instance.
fix
Use libFoxHound.new(_Fable) instead of new libFoxHound().
error Cannot read property 'query' of undefined
cause Calling buildReadQuery() before complete configuration.
fix
Ensure all necessary methods (setScope, setDialect, etc.) are called before buildReadQuery().
error Error: Dialect 'XYZ' not supported
cause Using an unsupported dialect string.
fix
Use one of: 'MySQL', 'PostgreSQL', 'MSSQL', 'SQLite', 'ALASQL', 'English', or 'MeadowEndpoints'.
gotcha Requires a Fable instance; cannot be instantiated directly.
fix Always pass a configured Fable object to libFoxHound.new().
deprecated The 'setDialect' method is deprecated in favor of 'dialect'.
fix Use .dialect('MySQL') instead of .setDialect('MySQL').
breaking Query parameters are now named with a suffix (e.g., :Genre_w0) to avoid collisions across multiple filters.
fix Update any code that assumes fixed parameter names; use the parameters object returned.
npm install foxhound
yarn add foxhound
pnpm add foxhound

Create a query instance with a Fable object, chain configuration methods to build a SELECT query for MySQL, then log the SQL and parameters.

const libFable = require('fable');
const libFoxHound = require('foxhound');

const _Fable = new libFable({});
const tmpQuery = libFoxHound.new(_Fable);

tmpQuery
    .setScope('Books')
    .setDataElements(['Title', 'Author', 'PublishedYear'])
    .addFilter('Genre', 'Science Fiction')
    .addSort({Column: 'PublishedYear', Direction: 'Descending'})
    .setCap(25)
    .setDialect('MySQL')
    .buildReadQuery();

console.log(tmpQuery.query.body);
// => SELECT `Title`, `Author`, `PublishedYear` FROM `Books`
//    WHERE `Books`.`Genre` = :Genre_w0 ORDER BY PublishedYear DESC LIMIT 25;

console.log(tmpQuery.query.parameters);
// => { Genre_w0: 'Science Fiction' }