// CreateOne saves provided model instance to database
CreateOne saves provided model instance to database
// CreateOne saves provided model instance to database
func (this *UserRepository) CreateOne(request *mrequest.UserCreate) (*mongo.InsertOneResult, error) {
	password, e := helper.Encrypt(request.Password)
	if e != nil {
		return nil, e
	}
	request.Password = password
	err := this.ValidateRoles(request.Roles)
	if err != nil {
		return nil, err
	}
	return this.users.InsertOne(context.Background(), request)
}
func ( this * UserRepository ) CreateOne ( request * mrequest . UserCreate ) ( * mongo . InsertOneResult , error ) { password , e := helper . Encrypt ( request . Password ) if e != nil { return nil , e } request . Password = password err := this . ValidateRoles ( request . Roles ) if err != nil { return nil , err } return this . users . InsertOne ( context . Background ( ) , request ) }
CreateOne saves provided model instance to database
CreateOne saves provided model instance to database
// encript password // validate roles exist in db // save user to database