/** * Created by Tony on 2016/12/23. */ var mongoose = require('mongoose'); var smartcostdb = require('./../db/smartcostdb'); //var Schema = smartcostdb.mongoose.Schema; var Schema = mongoose.Schema; var CtrlSchema = new Schema({ "ID" : String, "Shrink" : String, "ShowZero" : String, "Horizon" : String, "Vertical" : String, "Wrap" : String }); var Control = smartcostdb.mongoose.model("com_ctrls", CtrlSchema); //var Control = smartcostdb.model("com_ctrls", CtrlSchema); var CtrlDAO = function(){}; //根据id CtrlDAO.prototype.get = function(id, callback){ Control.find({ID: id}, function(err, templates){ if(templates.length){ callback(false, templates[0]); } else{ callback('查找不到报表模板!'); } }) } CtrlDAO.prototype.getAll = function(id, callback){ Control.find({}, function(err, templates){ if(templates.length){ callback(false, templates); } else{ callback('查找不到报表模板!'); } }) } module.exports = new CtrlDAO();