/**
 * 
 * @param {*} model 
 * @param {*} data 
 * @param {*} config 
  * @param {('one'|'many')} mode
 */


function beforeCreateDocument (model,data,config,mode='one'){
   var model =  config?.getOneCollection(model)
   if(model?.auth?.enabled && model?.auth?.defaultRole?.length>10){
        if(mode=='one'){
            data.data.roleId = model.auth.defaultRole
        }
        if(mode=='many'){
            data.data.map(el=>{
                el.roleId = model.auth.defaultRole
            })
        }

   
   }
}



module.exports ={
    beforeCreateDocument
}