emquery
v1.0.3
Published
construct a mongodb update query data from an object
Downloads
192
Readme
emquery
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