node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

mongoobject

mongoobject

escapes $ and . in object keys so you can store objects in MongoDB.

Installation

npm install mongoobject

Usage

var mongoobject = require('mongoobject');
 
var objectToSaveInMongo = mongoobject.escape(myObject);
var mongoobject = require('mongoobject');
 
var myObject = mongoobject.unescape(myObjectFromMongo);
 

You can also escape and unescape just one property name

var escapedPropertyName = mongoobject.escapeKey('$mypropertyName');
 
var unescapedPropertyName = momgoobject.unescapeKey('\uff04myPropertyName');

License

MIT