rpt_temp_data.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Created by Tony on 2016/12/28.
  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 RptTemplateDataSchema = new Schema({
  9. "Data_Key": String,
  10. "discrete_data": Array,
  11. "master_data": Array,
  12. "detail_data": Array
  13. });
  14. var TemplateData = smartcostdb.mongoose.model("temp_tpl_datas", RptTemplateDataSchema);
  15. //var TemplateData = smartcostdb.model("temp_tpl_datas", RptTemplateDataSchema);
  16. var RplTplDataDAO = function(){};
  17. //根据id获取临时数据
  18. RplTplDataDAO.prototype.get = function(tpl_id, callback){
  19. //TemplateData.find({"Data_Key": tpl_id}, function(err, templates){
  20. //TemplateData.find({}, function(err, templates){
  21. TemplateData.find({"Data_Key": tpl_id}, function(err, templates){
  22. if(templates.length){
  23. callback(false, templates[0]);
  24. }
  25. else{
  26. callback('查找不到模板临时数据!');
  27. }
  28. })
  29. }
  30. module.exports = new RplTplDataDAO();