testTableHelper.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Created by benzhan on 15/8/10.
  3. */
  4. require('../extensions/function_extend.js');
  5. var TableHelper = require('../framework/lib/TableHelper.js');
  6. var objHelper = new TableHelper('cUser', 'Web');
  7. var allDeferred = objHelper.getAll();
  8. allDeferred.then(function(rows) {
  9. console.log('getAll');
  10. console.log(rows);
  11. }, console.error);
  12. var keyWord = {_field:'userName'};
  13. var colDeferred = objHelper.getCol({}, keyWord);
  14. colDeferred.then(function(col) {
  15. console.log('getCol');
  16. console.log(col);
  17. }, console.error);
  18. var where = {userId:13501489295};
  19. var colDeferred = objHelper.getRow(where);
  20. colDeferred.then(function(row) {
  21. console.log('getRow');
  22. console.log(row);
  23. }, console.error);
  24. var data = {userName:'123456', userId:123456, anotherPwd:123};
  25. var addDeferred = objHelper.addObject(data);
  26. addDeferred.then(function(result) {
  27. console.log('addObject');
  28. console.log(result);
  29. }, console.error);
  30. var where = {userId:123456};
  31. var newData = {userName:'123456798'};
  32. var updateDeferred = objHelper.updateObject(newData, where);
  33. updateDeferred.then(function(result) {
  34. console.log('updateObject');
  35. console.log(result);
  36. });
  37. var where = {userId:123456};
  38. var keyWord = {_field:'userName'};
  39. var oneDeferred = objHelper.getOne(where, keyWord);
  40. oneDeferred.then(function(one) {
  41. console.log('getOne');
  42. console.log(one);
  43. }, console.error);
  44. var data = {userName:'1234526', userId:123456, anotherPwd:123};
  45. var replaceDeferred = objHelper.replaceObject(data);
  46. replaceDeferred.then(function(result) {
  47. console.log('replaceObject');
  48. console.log(result);
  49. }, console.error);
  50. var where = {userId:123456};
  51. var delDeferred = objHelper.delObject(where);
  52. delDeferred.then(function(result) {
  53. console.log('delObject');
  54. console.log(result);
  55. }, console.error);