flexbiz-server
Version:
Flexible Server
7 lines (6 loc) • 2.63 kB
JavaScript
'use strict';const validator=require("../libs/validator"),ctds2Scheam=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_dvcs:{type:String,required:!0,maxlength:1024},group_id:{type:String,trim:!0,maxlength:1024},ct_theo:{type:String,default:"thang"},hl_tu_ngay:Date,hl_den_ngay:Date,cach_tinh:{type:String,default:"1"},tk_no:[String],tk_no_gt:Boolean,tk_co:[String],tk_co_gt:Boolean,ma_kho:{type:String,uppercase:!0,trim:!0,maxlength:32},ten_kho:String,ma_kh:{type:String,uppercase:!0,trim:!0,
maxlength:32},ten_kh:String,nh_kh:[String],nh_kh_lt:Boolean,nh_kh2:[String],nh_kh3:[String],nh_kh4:[String],nh_kh5:[String],ma_nv:{type:String,uppercase:!0,trim:!0,maxlength:32},ten_nv:String,ma_nvt:[String],ma_nvt_lt:Boolean,ma_nvt2:[String],ma_nvt3:[String],ma_nvt4:[String],ma_nvt5:[String],ma_dt:{type:String,uppercase:!0,trim:!0,maxlength:32},ma_bp:{type:String,uppercase:!0,trim:!0,maxlength:32},ma_phi:{type:String,uppercase:!0,trim:!0,maxlength:32},ma_hd:{type:String,uppercase:!0,trim:!0,maxlength:32},
ma_sp:{type:String,uppercase:!0,trim:!0,maxlength:32},chi_tieu:{type:Number,default:0},chi_tieu_thang:{type:Number,default:0},chinh_sach_hoa_hong:[],quan_ly:{type:Boolean,default:!1},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});ctds2Scheam.validate={ma_dvcs:validator.existsDvcs};
(global.configs||{}).createIndexes&&(ctds2Scheam.index({id_app:1,group_id:1,ma_dvcs:1,ma_kho:1,ma_nv:1}),ctds2Scheam.index({ma_kho:"text",ma_nv:"text",ten_nv:"text",ten_kho:"text"},{name:"ctds2_index_text"}),ctds2Scheam.index({ct_theo:1}),ctds2Scheam.index({hl_tu_ngay:-1}),ctds2Scheam.index({hl_den_ngay:-1}),ctds2Scheam.index({ma_dt:1}),ctds2Scheam.index({ma_bp:1}),ctds2Scheam.index({ma_phi:1}),ctds2Scheam.index({tk_co:1}),ctds2Scheam.index({tk_no:1}),ctds2Scheam.index({ma_kh:1}),ctds2Scheam.index({ma_hd:1}),
ctds2Scheam.index({ma_sp:1}),ctds2Scheam.index({nh_kh:1}),ctds2Scheam.index({nh_kh2:1}),ctds2Scheam.index({nh_kh3:1}),ctds2Scheam.index({nh_kh4:1}),ctds2Scheam.index({nh_kh5:1}),ctds2Scheam.index({ma_nvt:1}),ctds2Scheam.index({ma_nvt2:1}),ctds2Scheam.index({ma_nvt3:1}),ctds2Scheam.index({ma_nvt4:1}),ctds2Scheam.index({ma_nvt5:1}),ctds2Scheam.index({status:1}),ctds2Scheam.index({user_created:1,visible_to:1,visible_to_users:1}));
ctds2Scheam.pre("save",function($next$$){this.chi_tieu_thang="quy"==this.ct_theo?this.chi_tieu/3:"nam"==this.ct_theo?this.chi_tieu/12:this.chi_tieu;$next$$()});module.exports=mongoose.models.ctds2||mongoose.model("ctds2",ctds2Scheam);