// LoadEthnicSubgroups allows an eager lookup of values, cached into the
// loaded structs of the objects. This is for a 1-M or N-M relationship.
LoadEthnicSubgroups allows an eager lookup of values, cached into the
loaded structs of the objects. This is for a 1-M or N-M relationship.
// LoadEthnicSubgroups 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 (ethnicGroupL) LoadEthnicSubgroups(ctx context.Context, e boil.ContextExecutor, singular bool, maybeEthnicGroup interface{}, mods queries.Applicator) error {
	var slice []*EthnicGroup
	var object *EthnicGroup
	if singular {
		object = maybeEthnicGroup.(*EthnicGroup)
	} else {
		slice = *maybeEthnicGroup.(*[]*EthnicGroup)
	}
	args := make([]interface{}, 0, 1)
	if singular {
		if object.R == nil {
			object.R = &ethnicGroupR{}
		}
		args = append(args, object.EthnicGroupID)
	} else {
	Outer:
		for _, obj := range slice {
			if obj.R == nil {
				obj.R = &ethnicGroupR{}
			}
			for _, a := range args {
				if a == obj.EthnicGroupID {
					continue Outer
				}
			}
			args = append(args, obj.EthnicGroupID)
		}
	}
	query := NewQuery(qm.From(`ethnic_subgroup`), qm.WhereIn(`ethnic_group_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 ethnic_subgroup")
	}
	var resultSlice []*EthnicSubgroup
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice ethnic_subgroup")
	}
	if err = results.Close(); err != nil {
		return errors.Wrap(err, "failed to close results in eager load on ethnic_subgroup")
	}
	if err = results.Err(); err != nil {
		return errors.Wrap(err, "error occurred during iteration of eager loaded relations for ethnic_subgroup")
	}
	if len(ethnicSubgroupAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(ctx, e); err != nil {
				return err
			}
		}
	}
	if singular {
		object.R.EthnicSubgroups = resultSlice
		for _, foreign := range resultSlice {
			if foreign.R == nil {
				foreign.R = &ethnicSubgroupR{}
			}
			foreign.R.EthnicGroup = object
		}
		return nil
	}
	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.EthnicGroupID == foreign.EthnicGroupID {
				local.R.EthnicSubgroups = append(local.R.EthnicSubgroups, foreign)
				if foreign.R == nil {
					foreign.R = &ethnicSubgroupR{}
				}
				foreign.R.EthnicGroup = local
				break
			}
		}
	}
	return nil
}
func ( ethnicGroupL ) LoadEthnicSubgroups ( ctx context . Context , e boil . ContextExecutor , singular bool , maybeEthnicGroup interface { } , mods queries . Applicator ) error { var slice [ ] * EthnicGroup var object * EthnicGroup if singular { object = maybeEthnicGroup . ( * EthnicGroup ) } else { slice = * maybeEthnicGroup . ( * [ ] * EthnicGroup ) } args := make ( [ ] interface { } , 0 , 1 ) if singular { if object . R == nil { object . R = & ethnicGroupR { } } args = append ( args , object . EthnicGroupID ) } else { Outer : for _ , obj := range slice { if obj . R == nil { obj . R = & ethnicGroupR { } } for _ , a := range args { if a == obj . EthnicGroupID { continue Outer } } args = append ( args , obj . EthnicGroupID ) } } query := NewQuery ( qm . From ( `ethnic_subgroup` ) , qm . WhereIn ( `ethnic_group_id in ?` , args ... ) ) if mods != nil { mods . Apply ( query ) } results , err := query . QueryContext ( ctx , e ) if err != nil { return errors . Wrap ( err , " " ) } var resultSlice [ ] * EthnicSubgroup 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 ( ethnicSubgroupAfterSelectHooks ) != 0 { for _ , obj := range resultSlice { if err := obj . doAfterSelectHooks ( ctx , e ) ; err != nil { return err } } } if singular { object . R . EthnicSubgroups = resultSlice for _ , foreign := range resultSlice { if foreign . R == nil { foreign . R = & ethnicSubgroupR { } } foreign . R . EthnicGroup = object } return nil } for _ , foreign := range resultSlice { for _ , local := range slice { if local . EthnicGroupID == foreign . EthnicGroupID { local . R . EthnicSubgroups = append ( local . R . EthnicSubgroups , foreign ) if foreign . R == nil { foreign . R = & ethnicSubgroupR { } } foreign . R . EthnicGroup = local break } } } return nil }
LoadEthnicSubgroups allows an eager lookup of values, cached into the
loaded structs of the objects.
LoadEthnicSubgroups allows an eager lookup of values cached into the loaded structs of the objects .