cobalt.nodes.update.js 875 B

1234567891011121314151617181920212223
  1. /* Remove this line if you want to try out the updating mechanism
  2. //Sample update script that covers the scenario of a plugin that previously
  3. //have been updated to v.1 but currently is v.2
  4. $(document).bind('cobalt-update', function(evt, cobalt, db, updates) {
  5. if (typeof(updates['cobaltnodes'])!='undefined') {
  6. var update = updates.cobaltnodes;
  7. switch (parseInt(update[0], 10)) {
  8. case 0:
  9. db.transaction(function (transaction) {
  10. //Do some changes needed to upgrade to rev 1
  11. console.log('Updating to v.1');
  12. cobalt.updateVersion(transaction, 'cobaltnodes', 1);
  13. });
  14. case 1:
  15. db.transaction(function (transaction) {
  16. //Do some changes needed to upgrade to rev 2
  17. console.log('Updating to v.2');
  18. cobalt.updateVersion(transaction, 'cobaltnodes', 2);
  19. });
  20. }
  21. }
  22. });
  23. //*/