user.storage.factory.js 970 B

1234567891011121314151617181920212223242526272829303132333435
  1. angular.module('odoo')
  2. /**
  3. * -----------------------------------------------------------------------------
  4. * Description: Local storage manager for users data
  5. * -----------------------------------------------------------------------------
  6. */
  7. .factory('userStorage', function () {
  8. // Save user data to local storage
  9. var save = function (data, success, error) {
  10. var sql = 'INSERT INTO user(remote_id, host, port, database, username, password) VALUES(?, ?, ?, ?, ?, ?)';
  11. db.executeSql(sql, data, function (result) {
  12. success(result.insertId);
  13. }, function (err) {
  14. error(err);
  15. });
  16. };
  17. var remove = function (success, error) {
  18. var sql = 'DELETE FROM user';
  19. db.executeSql(sql, [], function(result) {
  20. success(result.rowsAffected);
  21. }, function(err) {
  22. error(err);
  23. });
  24. }
  25. return {
  26. save: save,
  27. remove: remove
  28. }
  29. });