mongoify

1.1.0 • Public • Published

mongoify

Converts:

{
  foo: { bar: 1 },
  date: new Date('2014-01-01T00:00:00Z'),
  regex: /foo/i,
  bla: undefined
}

To this:

{
  foo: { bar: 1 },
  date: { $date: '2014-01-01T00:00:00Z' },
  regex: { $regex: 'foo', $options: 'i' },
  bla: { $undefined: true }
}

browser support

Build status js-standard-style

What?

This is called MongoDB Extended JSON.

Why?

So that you can JSON.stringify the object for easy storage or transport.

Installation

npm install mongoify

Usage

var mongoify = require('mongoify')
 
var obj = { date: new Date('2014-01-01T00:00:00Z') }
 
mongoify(obj)
 
console.log(JSON.stringify(obj))

License

MIT

Package Sidebar

Install

npm i mongoify

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • watson