https://github.com/lestoni/emquery
Construct mongoDB/mongoose update queries in ease
https://github.com/lestoni/emquery
Last synced: about 1 year ago
JSON representation
Construct mongoDB/mongoose update queries in ease
- Host: GitHub
- URL: https://github.com/lestoni/emquery
- Owner: lestoni
- License: other
- Created: 2015-04-25T16:35:26.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T17:41:40.000Z (almost 3 years ago)
- Last Synced: 2024-10-13T08:43:50.851Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## emquery
[](https://travis-ci.org/lestoni/emquery)
[](https://nodei.co/npm/emquery/)
Construct a mongodb query update for embedded documents.
Works great with mongoose.
## install
```sh
$ npm install emquery
```
## example
```sh
$ node example.js
```
```javascript
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