Last active
March 17, 2025 06:47
-
-
Save joselcvarela/71343f2a055093b94e41562b4dd71244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ip = "localhost" | |
var dbName = "DBNAME" | |
var viewType = "VIEWTYPE" | |
var viewName = "VIEWNAME" | |
$.getJSON("http://"+ip+":5984/"+dbName+"/_design/"+viewType+"/_view/"+viewName+"/", function(data) { | |
data.rows.forEach(function (doc) { | |
var __id = doc.value._id | |
delete doc.value._id | |
var newDoc = doc.value | |
newDoc.values = Object.assign({}, doc.value.values, {newValue: false}) | |
$.ajax({ | |
dataType: 'json', | |
data: JSON.stringify(newDoc), | |
url: "http://"+ip+":5984/"+dbName+"/" + __id, | |
type: 'PUT', | |
success: function(result) { | |
console.log("Updated document with id " + __id); | |
} | |
}); | |
}); | |
}); |
Comments are disabled for this gist.