dirac-cast-to-json
v0.0.1
Published
Cast values to JSON before a db operation. Traverses schema for the specified types (default `json`) and sets up dirac before filters for the specified operations (default `insert`, and `update`) to JSON.stringify the values
Readme
Dirac cast to JSON
Database middleware for dirac that automatically stringifies fields.
Install
npm install dirac-cast-to-jsonUsage
var dirac = require('dirac');
dirac.use( require('dirac-cast-to-json')() );Options
By default, the options are:
{
operations: ['insert', 'update']
, types: ['json']
}var dirac = require('dirac');
dirac.use( require('dirac-cast-to-json')({
operations: ['insert', 'update', 'myCustomUpdateFunction']
, types: ['json', 'my-special-json-type']
}));Tests
npm test