1.0.1 • Published 7 years ago
transform-props v1.0.1
Transform Props
Transform @object properties using @propKeys and @transformers. ES5 compatible.
Installation
$ npm install transform-props
Usage
var transformProps = require('transform-props');
function castToString(arg) {
return String(arg);
}
var doc = new MongooseModel({ subDoc: { foo: 'bar' }});
var docObj = doc.toObject();
transformProps(docObj, castToString, '_id');
console.log(typeof docObj._id); // 'string'
console.log(typeof docObj.subDoc._id); // 'string'