mongodb-rest
mongodb-rest copied to clipboard
Mongodb dont update doc
I am unable to update any field of my project , since moving to MongoDB , I'm using server mongodb-rest REST API.
My function send and receive data return , but do not write in mongodb database .
I would like to help on this.
I using Restangular, and my code for get and update is:
$scope.updateItem = function(){ $http.put(API.db+ '/' +$scope.section+ '/' +$scope.item._id, $scope.item) .then(function(response) { //var id = getID(response.headers('Location')); //$state.go('admin.editItem', {section: $scope.section, id: id}); console.log(response); }) .catch(function(err, status) { toast.msgToast($scope.section + ' ...ocorreu um erro ao criar o item!'); }) .finally(function(){ toast.msgToast($scope.section + ' ...item atualizado!'); });
};
$scope.loadItem = function(){ ApiRestangular.one($scope.section, $stateParams.id).get().then(function(item) { $scope.item = item; }); };
- Sorry , I could not open the previous ..
Does it work if you don't use Restangular?
I have the same problem, Simple PUT request using angular's native $http service won't update the document, Here's my code
let data = angular.copy(ctrl.element);
$http.put(`%MYSERVER%/mydb/collection/${id}`, data)
.then(res => alert('changes saved'), err => console.errror(err));
i get the alert "changes saved" but the document stays the same