flexbiz-server
Version:
Flexible Server
4 lines (3 loc) • 1.06 kB
JavaScript
;const chudethaoluanSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},title:{type:String,required:!0,maxlength:1024},title_en:{type:String,maxlength:1024},description:{type:String},description_en:{type:String},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:""},shared:Boolean});
(global.configs||{}).createIndexes&&(chudethaoluanSchema.index({id_app:1}),chudethaoluanSchema.index({title:"text"}),chudethaoluanSchema.index({status:1}),chudethaoluanSchema.index({user_created:1,visible_to:1,visible_to_users:1}));const model=mongoose.models.chudethaoluan||mongoose.model("chudethaoluan",chudethaoluanSchema);
model.getInfo=async($condition$$,$fields$$)=>new Promise(($resolve$$,$reject$$)=>{model.findOne($condition$$).lean().exec(($e$$,$rs$$)=>{if($e$$||!$rs$$)return $reject$$(Error($e$$?$e$$.message:"Can't find info"));$resolve$$($fields$$?$rs$$[$fields$$]:$rs$$)})});module.exports=model;