ashleydavis / mongodb-rest

REST Server for MongoDB (using node.js)
GNU Lesser General Public License v3.0
75 stars 34 forks source link

Mongodb dont update doc #14

Open marcoriesco opened 9 years ago

marcoriesco commented 9 years ago

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; }); };

ashleydavis commented 8 years ago

Does it work if you don't use Restangular?

dcohenb commented 8 years ago

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