Skip to content

Commit

Permalink
(pouchdb/pouchdb#3056) - _changes with POST
Browse files Browse the repository at this point in the history
`_changes` needs to accept POST as well as GET
because of doc_ids.
  • Loading branch information
nolanlawson authored and daleharvey committed Dec 2, 2014
1 parent 4b36474 commit 1f81603
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/routes/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ module.exports = function(app, PouchDB) {
});

// Monitor database changes
app.get('/:db/_changes', function (req, res, next) {
function changes(req, res, next) {
req.query.query_params = JSON.parse(JSON.stringify(req.query));

if (req.body && req.body.doc_ids) {
req.query.doc_ids = req.body.doc_ids;
}

if (req.query.feed === 'continuous' || req.query.feed === 'longpoll') {
var heartbeatInterval;
var timeout;
Expand Down Expand Up @@ -177,9 +181,12 @@ module.exports = function(app, PouchDB) {
};
req.db.changes(req.query);
}
});
}

app.get('/:db/_changes', changes);
app.post('/:db/_changes', jsonParser, changes);

// DB Compaction
// DB Compaction
app.post('/:db/_compact', jsonParser, function (req, res, next) {
req.db.compact(req.query, function (err, response) {
if (err) return utils.sendError(res, err);
Expand Down

0 comments on commit 1f81603

Please sign in to comment.