Update data from table to mongodb

754 Views Asked by At

Is there any framework or technique to simply update data edited in table and stored in mongoDB

I am using angularjs, node.js and mongoDB.

My 'by hand' idea is to:

  1. track edits in angular table that will return json with updated fields
  2. send REST request for update edited fields with proper document id
1

There are 1 best solutions below

0
On

Using the Angular JS, we can do all CRUD operation. For your question i have answer,

In HTML

<tr ng-repeat="list in getList">

                      <td>{{$index+1}}</td>
                    <td>{{list.firstname}}</td>
                    <td>{{list.lastname}}</td>
                    <td class=" last"><button type="button" class="fa fa-edit btn btn-primary" ng-click="edit($index,list)"></button>
                    </td>
                  </tr>

In controller,

 $scope.edit=function(idx,list){
    $scope.<name of ng-model>=angular.copy(list)
    flag=idx;        
}

and now in controller where to saving, check the data in save() function, where the list is existing in the table. If yes the call update(), else call add().