My Angular (Ionic) code gets the doc in the db by $index, open a modal with a form to change data and finally delta-pouch saves the updated doc. But instead of updating the doc, delta pouch creates a new one..
$scope.editTerritory = function(index){
$scope.modalEdit.show();
$scope.doEditTerritory=function(territory) {
pouch.save({
$id: index.$id,
name: territory.name,
number: territory.number
});
};
};
index._id console log correctly respond with id of the requested doc. Same thing for territory object. Why delta-pouch creates new one?
That's the point of delta-pouch – every update or delete results in a new document. If you run into a true bug, though, you should file it at https://github.com/redgeoff/delta-pouch/issues. The delta-pouch plugin is only about a week old; there may be some bugs! :)
I've released an all-in-one angularjs binding called factoryng that you can use to incorporate delta pouch (or vanilla pouch) into your angular code. Let me know what you think!
I recommend that you take a look at the Contacts example as it demonstrates how to save changes. Note: factoryng can currently be used with delta-pouch, pouch and firebase so you'll need to specify the delta-pouch adapter for your project.