Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 864 Bytes

README.md

File metadata and controls

46 lines (31 loc) · 864 Bytes

emquery

Build Status NPM

Construct a mongodb query update for embedded documents.

Works great with mongoose.

install

  $ npm install emquery

example

  $ node example.js
  const emquery = require('emquery');

  const UserModel = require('../models/user');

  app.put('/users/:id', function updateUser(req, res, next) {
    const updates = {
      $set: emquery(req.body);
    };

    User.findByIdAndUpdate(user._id, updates, function(err, user) {
      if(err) return next(err);
      res.json(user);
    });
  });

API

emquery({}#object} = require('emquery')

Pass in the object to parsed to a query.

license

MIT