rpt_control.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Created by Tony on 2016/12/23.
  3. */
  4. var mongoose = require('mongoose');
  5. var smartcostdb = require('./../db/smartcostdb');
  6. //var Schema = smartcostdb.mongoose.Schema;
  7. var Schema = mongoose.Schema;
  8. var CtrlSchema = new Schema({
  9. "ID" : String,
  10. "Shrink" : String,
  11. "ShowZero" : String,
  12. "Horizon" : String,
  13. "Vertical" : String,
  14. "Wrap" : String
  15. });
  16. var Control = smartcostdb.mongoose.model("com_ctrls", CtrlSchema);
  17. //var Control = smartcostdb.model("com_ctrls", CtrlSchema);
  18. var CtrlDAO = function(){};
  19. //根据id
  20. CtrlDAO.prototype.get = function(id, callback){
  21. Control.find({ID: id}, function(err, templates){
  22. if(templates.length){
  23. callback(false, templates[0]);
  24. }
  25. else{
  26. callback('查找不到报表模板!');
  27. }
  28. })
  29. }
  30. CtrlDAO.prototype.getAll = function(id, callback){
  31. Control.find({}, function(err, templates){
  32. if(templates.length){
  33. callback(false, templates);
  34. }
  35. else{
  36. callback('查找不到报表模板!');
  37. }
  38. })
  39. }
  40. module.exports = new CtrlDAO();