testTableHelper.js 1.7 KB

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