Akshay Seth
Akshay Seth

Reputation: 1272

How to update a single element in mongodb

$http.put('/api/datas/' + val[$rootScope.id]._id,val[$rootScope.id].values[0].quantity =$scope.ass);

Above mentioned is the code where val[$rootScope.id]._id is the id of the field in mongodb and val[$rootScope.id].values[0].quantity is the quantity which is to be updated and $scope.ass is the updated value.

How can I update quantity value on MongoDB ?

Upvotes: 0

Views: 68

Answers (1)

Md Nazmul Hossain
Md Nazmul Hossain

Reputation: 2923

Try with this code for update database value :

db.databaseName.update(
   { _id: value_of_ID},
   {
       quantity : value_of_quantity;
   },
   { upsert: true }
)

Upvotes: 1

Related Questions