chameleon-case

0.0.3 • Public • Published

Object key Changer that you can pick some classes which should be ignored from key changing. For example, you can customize it for ignoring 'Date' and 'ObjectID' for mongoose object

Usage

var cc = require('chameleon-case');
cc.camelcase({ hello_world: { hello_world: [ { hello_world: 1 } ] } });
// {helloWorld: {helloWorld: [{helloWorld: 1}]}} 

cc.snakecase({ helloWorld: { helloWorld: [ { helloWorld: 1 } ] } } );
// {hello_world: {hello_world: [{hello_world: 1}]}} 


/* with Mongoose */
cc.option({
    ignoreClass: ['Date', 'ObjectID'] // Date is for some timestamps. ObjectID is for sub document id
  })
MyObject.findOne().lean().then(doc => cc.camelcase(doc)) // Note that you should call lean for avoiding infinite loop

Package Sidebar

Install

npm i chameleon-case

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

4.95 kB

Total Files

4

Last publish

Collaborators

  • jinhochung