Skip to content

Instantly share code, notes, and snippets.

@joselcvarela
Last active October 25, 2018 08:19
Show Gist options
  • Save joselcvarela/c2dd8e16ce43eed21643dd52b52f589e to your computer and use it in GitHub Desktop.
Save joselcvarela/c2dd8e16ce43eed21643dd52b52f589e to your computer and use it in GitHub Desktop.
var ip = "http://localhost"
var dbName = "DB_NAME"
var viewType = "VIEW_TYPE"
var viewName = "VIEW_NAME"
$.getJSON(ip+":5984/"+dbName+"/_design/"+viewType+"/_view/"+viewName+"/", function(data) {
    data.rows.forEach(function (doc) {
        $.ajax({
            url: ip+":5984/"+dbName+"/" + doc.value._id + '?rev=' + doc.value._rev,
            type: 'DELETE',
            success: function(result) {
                console.log("Deleted document with id " + doc.value._id);
            }
        });
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment