// LoadPollsCountries allows an eager lookup of values, cached into the
// loaded structs of the objects. This is for a 1-M or N-M relationship.
LoadPollsCountries allows an eager lookup of values, cached into the
loaded structs of the objects. This is for a 1-M or N-M relationship.
// LoadPollsCountries allows an eager lookup of values cached into the // loaded structs of the objects . This is for a 1 - M or N - M relationship .
func (countryL) LoadPollsCountries(ctx context.Context, e boil.ContextExecutor, singular bool, maybeCountry interface{}, mods queries.Applicator) error {
	var slice []*Country
	var object *Country
	if singular {
		object = maybeCountry.(*Country)
	} else {
		slice = *maybeCountry.(*[]*Country)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &countryR{}
		}
		args = append(args, object.CountryID)
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &countryR{}
			}
			for _, a := range args {
				if a == obj.CountryID {
					continue Outer
				}
			}
			args = append(args, obj.CountryID)
		}
	}
	query := NewQuery(qm.From(`polls_country`), qm.WhereIn(`country_id in ?`, args...))
	if mods != nil {
		mods.Apply(query)
	}
	results, err := query.QueryContext(ctx, e)
	if err != nil {
		return errors.Wrap(err, "failed to eager load polls_country")
	}
	var resultSlice []*PollsCountry
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice polls_country")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results in eager load on polls_country")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for polls_country")
	}
	if len(pollsCountryAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(ctx, e); err != nil {
				return err
			}
		}
	}
	if singular {
		object.R.PollsCountries = resultSlice
		for _, foreign := range resultSlice {
			if foreign.R == nil {
				foreign.R = &pollsCountryR{}
			}
			foreign.R.Country = object
		}
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.CountryID == foreign.CountryID {
				local.R.PollsCountries = append(local.R.PollsCountries, foreign)
				if foreign.R == nil {
					foreign.R = &pollsCountryR{}
				}
				foreign.R.Country = local
				break
			}
		}
	}
	return nil
}
func ( countryL ) LoadPollsCountries ( ctx context . Context , e boil . ContextExecutor , singular bool , maybeCountry interface { } , mods queries . Applicator ) error { var slice [ ] * Country var object * Country if singular { object = maybeCountry . ( * Country ) } else { slice = * maybeCountry . ( * [ ] * Country ) } args := make ( [ ] interface { } , 0 , 1 ) if singular { if object . R == nil { object . R = & countryR { } } args = append ( args , object . CountryID ) } else { Outer : for _ , obj := range slice { if obj . R == nil { obj . R = & countryR { } } for _ , a := range args { if a == obj . CountryID { continue Outer } } args = append ( args , obj . CountryID ) } } query := NewQuery ( qm . From ( `polls_country` ) , qm . WhereIn ( `country_id in ?` , args ... ) ) if mods != nil { mods . Apply ( query ) } results , err := query . QueryContext ( ctx , e ) if err != nil { return errors . Wrap ( err , " " ) } var resultSlice [ ] * PollsCountry if err = queries . Bind ( results , & resultSlice ) ; err != nil { return errors . Wrap ( err , " " ) } if err = results . Close ( ) ; err != nil { return errors . Wrap ( err , " " ) } if err = results . Err ( ) ; err != nil { return errors . Wrap ( err , " " ) } if len ( pollsCountryAfterSelectHooks ) != 0 { for _ , obj := range resultSlice { if err := obj . doAfterSelectHooks ( ctx , e ) ; err != nil { return err } } } if singular { object . R . PollsCountries = resultSlice for _ , foreign := range resultSlice { if foreign . R == nil { foreign . R = & pollsCountryR { } } foreign . R . Country = object } return nil } for _ , foreign := range resultSlice { for _ , local := range slice { if local . CountryID == foreign . CountryID { local . R . PollsCountries = append ( local . R . PollsCountries , foreign ) if foreign . R == nil { foreign . R = & pollsCountryR { } } foreign . R . Country = local break } } } return nil }
LoadPollsCountries allows an eager lookup of values, cached into the
loaded structs of the objects.
LoadPollsCountries allows an eager lookup of values cached into the loaded structs of the objects .