cfg_style.js 980 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 StyleSchema = new Schema({
  9. "ID" : String,
  10. "border_style" : Array
  11. });
  12. let Style = smartcostdb.model("com_styles", StyleSchema, "com_styles");
  13. let StyleDAO = function(){};
  14. //根据id
  15. StyleDAO.prototype.get = function(id, callback){
  16. Style.find({ID: id}, '-_id', function(err, templates){
  17. if(templates.length){
  18. callback(false, templates[0]);
  19. }
  20. else{
  21. callback('no record was found!');
  22. }
  23. })
  24. }
  25. StyleDAO.prototype.getAll = function(id, callback){
  26. Style.find({}, '-_id', function(err, templates){
  27. if(templates.length){
  28. callback(false, templates);
  29. }
  30. else{
  31. callback('no record was found!');
  32. }
  33. })
  34. }
  35. module.exports = new StyleDAO();