rpt_tpl_data.js 994 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Created by Tony on 2016/12/28.
  3. */
  4. var mongoose = require('mongoose');
  5. var dbm = require("../../../config/db/db_manager");
  6. var smartcostdb = dbm.getCfgConnection("Reports");
  7. var Schema = mongoose.Schema;
  8. var RptTemplateDataSchema = new Schema({
  9. "Data_Key": String,
  10. "discrete_data": Array,
  11. "master_data": Array,
  12. "detail_data": Array
  13. });
  14. var TemplateData = smartcostdb.model("temp_tpl_data", RptTemplateDataSchema, "temp_tpl_data");
  15. var RplTplDataDAO = function(){};
  16. //根据id获取临时数据
  17. RplTplDataDAO.prototype.get = function(tpl_id, callback){
  18. TemplateData.find({"Data_Key": tpl_id}, function(err, templates){
  19. if(templates.length){
  20. callback(false, templates[0]);
  21. }
  22. else{
  23. callback('查找不到模板临时数据!');
  24. }
  25. })
  26. };
  27. RplTplDataDAO.prototype.getPromise = function(tpl_id, callback){
  28. return TemplateData.findOne({"Data_Key": tpl_id}).exec();
  29. }
  30. module.exports = new RplTplDataDAO();