coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Stop to update automatically #192

Open brunogonncalves opened 7 years ago

brunogonncalves commented 7 years ago

I have a problem, I want to save my entity if user submit the form clicking in a button, but when I set some value in entity object, my register is updated in my database !

entityObject.all().list(function(registers){

  var myRegister = registers[0];

  // myRegister is updated in my database
  myRegister.someValue = 'value';

  // I want to update this register just if user click to submit a for like this
  function clickEvent(){
    persistence.add(myRegister);
    persistence.flush(function(){
      // the register has been saved !
    });
  }

});