/**
 * Created by Tony on 2016/12/23.
 */
var mongoose = require('mongoose');
var dbm = require("../../../config/db/db_manager");
var smartcostdb = dbm.getCfgConnection("Reports");
var Schema = mongoose.Schema;
var CtrlSchema = new Schema({
    "ID" : String,
    "Shrink" : String,
    "ShowZero" : String,
    "Horizon" : String,
    "Vertical" : String,
    "Wrap" : String
});

var Control = smartcostdb.model("com_ctrls", CtrlSchema, "com_ctrls");

var 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();
