rpt_temp_data.js 972 B

123456789101112131415161718192021222324252627282930313233
  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_datas", RptTemplateDataSchema);
  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. //TemplateData.find({}, function(err, templates){
  20. TemplateData.find({"Data_Key": tpl_id}, function(err, templates){
  21. if(templates.length){
  22. callback(false, templates[0]);
  23. }
  24. else{
  25. callback('查找不到模板临时数据!');
  26. }
  27. })
  28. }
  29. module.exports = new RplTplDataDAO();