npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

mongoify

1.1.0

@watson

npmHomeRepoSnykSocket
Downloads:1
$ npm install mongoify
DailyWeeklyMonthlyYearly

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