FoxHound
raw JSON →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.
Common errors
error TypeError: libFoxHound is not a constructor ↓
error Cannot read property 'query' of undefined ↓
error Error: Dialect 'XYZ' not supported ↓
Warnings
gotcha Requires a Fable instance; cannot be instantiated directly. ↓
deprecated The 'setDialect' method is deprecated in favor of 'dialect'. ↓
breaking Query parameters are now named with a suffix (e.g., :Genre_w0) to avoid collisions across multiple filters. ↓
Install
npm install foxhound yarn add foxhound pnpm add foxhound Imports
- libFoxHound wrong
import libFoxHound from 'foxhound';correctconst libFoxHound = require('foxhound'); - new wrong
new libFoxHound();correctlibFoxHound.new(_Fable); - buildReadQuery
tmpQuery.buildReadQuery();
Quickstart
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' }