Reputation: 1431
I am trying to update an existing document in mongodb with node.js. But it does not seem to work. It do not even display the request call in the console. Please suggest what mistake I am doing or how I can I do the update operation in node.js with mongodb. Here is the code:
Node.js Code:
app.put('/addIssueId', function(req, res) {
console.log("Adding issue id")
console.log(req.body.issueKey)
impactMapFeature.update( {productName:req.params.productName, actor:req.body.actor, activity:req.body.activity,feature:req.body.feature},{issueKey:req.body.issueKey}, function ( err, data ) {
console.log("Updating" + data)
});
});
Angular Controller code:
var data = {
productName: $scope.productName,
actor: actor,
activity: impact,
feature : $('#feature').val(),
issueKey : data.key
};
$http.put('/addIssueId', data)
.success(function(data){
}).error(function(data){
console.log('Error in adding issueId' + data)
});
}
Upvotes: 0
Views: 830
Reputation: 1555
As chridam said, you are using req.params which is a route parameter. Either use the following route : /addIssueId/:productName
or pass your variable with a query parameter : /addIssueId?productName=productName
and {productName = req.query.productName, ... }
, or pass your variable as you are doing it in the body (then you just need to change req.params.productName
to req.body.productName
Upvotes: 1