lemonde/middlebot-oss — pull request #1 by neoziro (2014-05-12 13:09:45+00:00)
Title: Add a data option

A data option should be added to be able to format data before creating or destroying.

---

## middlebotOss.create(options)

Call create method on the provided index.

### Options

- `Index` index
- `Function` data
- If these key is not provided, `res.body` will be used as data object. The function have `req` and `res` as arguments and must return a plain object. If `false` is returned, do nothing.

### Example

```js
app.use(middlebotOss.create({
index: myIndex,
data: function (req, res) {
return res.body;
}
}));
```

## middlebotOss.destroy(options)

Call destroy method on the provided index.

### Options

- `Index` index
- `Function` data
- If these key is not provided, `req.query` will be used as data object. The function have `req` and `res` as arguments and must return a plain object. If `false` is returned, do nothing.

### Example

```js
app.use(middlebotOss.destroy({
index: myIndex,
data: function (req, res) {
return req.query;
}
}));
```