typicaljoe / taffydb

TaffyDB - an open source JavaScript Database for your browser
http://taffydb.com
MIT License
2.21k stars 285 forks source link

UPDATED database not reflecting when refreshing the webpage #110

Closed ksvsharsha closed 8 years ago

ksvsharsha commented 8 years ago

Hi, I am updating the TAFFY database using update() function and using get() function attaching it to a table. But once I refresh the page the updated data is not reflecting and old database is showing. similar is the case with insert() function also. Please help me

$scope.UpdateData = function() {
    var field=[];
    var row;
    var allfields=["ENTER RFID","ENTER RFP HIGH LEVEL DETAILS","ENTER RFP RECIEVE DATE","ENTER RESPONSE DUE DATE","ENTER RAG STATUS","ENTER BUSINESS DIVISION","ENTER NO OF POSITIONS","ENTER ROLE","ENTER EXPERIENCE","ENTER PRIMARY SKILLS","ENTER RESPONSIBILITIES","ENTER GE HIRING MANAGER","ENTER SUTHERLAND SPOC","ENTER REQUIREMENTS","ENTER REMARKS"];
    row=$window.prompt("Enter the row no to be edited","");
    $window.alert("Now enter the fields in the order");
    for (var i = 0; i < 15; i++) {

    field[i]=$window.prompt(allfields[i],"");           
    }

    database({index:row}).update({rfid:field[0],rfphighleveldetails:field[1],rfprecieveddate:field[2],responseduedate:field[3],ragstatus:field[4],businessdivision:field[5],nopositions:field[6],role:field[7],experience:field[8],primaryskills:field[9],responsibilities:field[10],gehiringmanager:field[11],sutherlandspoc:field[12],requirements:field[13],remarks:field[14]},true);
    $scope.names=database().get();

    //$window.alert(greeting);
  };
  $scope.InsertData=function(){
    var field=[];

    var allfields=["ENTER S.NO","ENTER RFID","ENTER RFP HIGH LEVEL DETAILS","ENTER RFP RECIEVE DATE","ENTER RESPONSE DUE DATE","ENTER RAG STATUS","ENTER BUSINESS DIVISION","ENTER NO OF POSITIONS","ENTER ROLE","ENTER EXPERIENCE","ENTER PRIMARY SKILLS","ENTER RESPONSIBILITIES","ENTER GE HIRING MANAGER","ENTER SUTHERLAND SPOC","ENTER REQUIREMENTS","ENTER REMARKS"];

    $window.alert("Now enter the fields in the order");
    for (var i = 0; i < 16; i++) {

    field[i]=$window.prompt(allfields[i],"");   
    //$window.alert(field[i]);

    }

    database.insert({"index":field[0],"rfid":field[1],"rfphighleveldetails":field[2],"rfprecieveddate":field[3],"responseduedate":field[4],"ragstatus":field[5],"businessdivision":field[6],"nopositions":field[7],"role":field[8],"role":field[9],"experience":field[10],"primaryskills":field[11],"responsibilities":field[12],"gehiringmanager":field[13],"sutherlandspoc":field[14],"requirements":field[15],"remarks":field[16]},true

    );
    $scope.names=database().get();

  };

Please help me with this...

mmikowski commented 8 years ago

TaffyDB does not persist data across page reloads. If you want to do that, you will need to serialize the TaffyDB data to local storage on page unload, and then read it in on page load.