/** * Created by Tony on 2017/6/14. */ let mongoose = require('mongoose'); let dbm = require("../../../config/db/db_manager"); let smartcostdb = dbm.getCfgConnection("Reports"); let Schema = mongoose.Schema; let FormatSchema = new Schema({ "ID" : String, "CfgDispName": String, "Shrink" : String, "ShowZero" : String, "Horizon" : String, "Vertical" : String, "Wrap" : String }); let FontSchema = new Schema({ "ID" : String, "Name" : String, "CfgDispName": String, "FontHeight" : String, "FontColor" : String, "FontBold" : String, "FontItalic" : String, "FontUnderline" : String, "FontStrikeOut" : String, "FontAngle" : String }); let LineSchema = new Schema({ "Position": String, "LineWeight": String, "DashStyle": String, "Color": String }); let StyleSchema = new Schema({ "ID" : String, "CfgDispName": String, "border_style" : [LineSchema] }); let RptCfgSchema = new Schema({ "userId" : String, "fonts": [FontSchema], "borders" : [StyleSchema], "formats" : [FormatSchema] }); let Rpt_Cfg_Mdl = smartcostdb.model("rpt_cfg", RptCfgSchema, "rpt_cfg"); class RptCfgDAO { getByUserId(userId, callback){ Rpt_Cfg_Mdl.find({userId: userId}, '-_id', function(err, templates){ if(templates.length){ callback(false, templates[0]); } else{ callback('no record was found!'); } }) }; getAll(id, callback){ Rpt_Cfg_Mdl.find({}, '-_id', function(err, templates){ if(templates.length){ callback(false, templates); } else{ callback('no record was found!'); } }) }; }; module.exports = new RptCfgDAO();