/** * Created by Tony on 2016/12/23. */ let mongoose = require('mongoose'); let dbm = require("../../../config/db/db_manager"); let smartcostdb = dbm.getCfgConnection("Reports"); let Schema = mongoose.Schema; let CtrlSchema = new Schema({ "ID" : String, "Shrink" : String, "ShowZero" : String, "Horizon" : String, "Vertical" : String, "Wrap" : String }); let Control = smartcostdb.model("com_ctrls", CtrlSchema, "com_ctrls"); let CtrlDAO = function(){}; //根据id CtrlDAO.prototype.get = function(id, callback){ Control.find({ID: id}, '-_id', function(err, templates){ if(templates.length){ callback(false, templates[0]); } else{ callback('no record was found!'); } }) } CtrlDAO.prototype.getAll = function(id, callback){ Control.find({}, '-_id', function(err, templates){ if(templates.length){ callback(false, templates); } else{ callback('no record was found!'); } }) } module.exports = new CtrlDAO();