dirac-cast-to-json

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

npm install dirac-cast-to-json
4 downloads in the last month

Dirac cast to JSON

Database middleware for dirac that automatically stringifies fields.

Install

npm install dirac-cast-to-json

Usage

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
npm loves you