An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

## emquery
[![Build Status](https://travis-ci.org/lestoni/emquery.svg)](https://travis-ci.org/lestoni/emquery)
[![NPM](https://nodei.co/npm/emquery.png?downloads=true&stars=true)](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