mongo-minify

0.1.1 • Public • Published

mongo-minify

Minifies a given MongoDB update query based on fields restrictions (inclusion or exclusion).

Example

var minify = require('mongo-minify');
 
minify({ $set: { a: 'b' }, $push: { 'c': 'd' } }, { a: 0 });
// { $push: { c: 'd' } }
 
minify({ $push: { c: 'd', e: 'f' }, $unset: { h: 1 } }, { e: 1 });
// { $push: { e: 'f' } }
 
minify({ $set: { 'name.first': 'Guillermo', age: 50 } }, { name: 1 });
// { $set: { 'name.first': 'Guillermo' } }

API

minify(query[, restrictions])

query is any update or findAndModify query passed to MongoDB.

restrictions is the fields selection format used with find*.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    9
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    9

Package Sidebar

Install

npm i mongo-minify

Weekly Downloads

9

Version

0.1.1

License

none

Last publish

Collaborators

  • rauchg