Skip to content

lestoni/emquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Construct mongoDB/mongoose update queries in ease

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published