Socket
Book a DemoInstallSign in
Socket

mongoify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoify

Converts an object with native JavaScript types and objects to MongoDB Extended JSON object

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

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

Keywords

mongodb

FAQs

Package last updated on 09 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts