cfg_control.js 1.0 KB

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