• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang queries.Bind函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vattle/sqlboiler/queries.Bind函数的典型用法代码示例。如果您正苦于以下问题:Golang Bind函数的具体用法?Golang Bind怎么用?Golang Bind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Bind函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: LoadAuthRole

// LoadAuthRole allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (authUserRoleL) LoadAuthRole(e boil.Executor, singular bool, maybeAuthUserRole interface{}) error {
	var slice []*AuthUserRole
	var object *AuthUserRole

	count := 1
	if singular {
		object = maybeAuthUserRole.(*AuthUserRole)
	} else {
		slice = *maybeAuthUserRole.(*AuthUserRoleSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &authUserRoleR{}
		args[0] = object.AuthRoleID
	} else {
		for i, obj := range slice {
			obj.R = &authUserRoleR{}
			args[i] = obj.AuthRoleID
		}
	}

	query := fmt.Sprintf(
		"select * from \"auth_role\" where \"auth_role_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load AuthRole")
	}
	defer results.Close()

	var resultSlice []*AuthRole
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice AuthRole")
	}

	if len(authUserRoleAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.AuthRole = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.AuthRoleID == foreign.AuthRoleID {
				local.R.AuthRole = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:auth_user_role.go


示例2: LoadPub

// LoadPub allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (featurepropPubL) LoadPub(e boil.Executor, singular bool, maybeFeaturepropPub interface{}) error {
	var slice []*FeaturepropPub
	var object *FeaturepropPub

	count := 1
	if singular {
		object = maybeFeaturepropPub.(*FeaturepropPub)
	} else {
		slice = *maybeFeaturepropPub.(*FeaturepropPubSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &featurepropPubR{}
		args[0] = object.PubID
	} else {
		for i, obj := range slice {
			obj.R = &featurepropPubR{}
			args[i] = obj.PubID
		}
	}

	query := fmt.Sprintf(
		"select * from \"pub\" where \"pub_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Pub")
	}
	defer results.Close()

	var resultSlice []*Pub
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Pub")
	}

	if len(featurepropPubAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.Pub = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.PubID == foreign.PubID {
				local.R.Pub = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:featureprop_pub.go


示例3: LoadStockcollections

// LoadStockcollections allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (contactL) LoadStockcollections(e boil.Executor, singular bool, maybeContact interface{}) error {
	var slice []*Contact
	var object *Contact

	count := 1
	if singular {
		object = maybeContact.(*Contact)
	} else {
		slice = *maybeContact.(*ContactSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &contactR{}
		args[0] = object.ContactID
	} else {
		for i, obj := range slice {
			obj.R = &contactR{}
			args[i] = obj.ContactID
		}
	}

	query := fmt.Sprintf(
		"select * from \"stockcollection\" where \"contact_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)
	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load stockcollection")
	}
	defer results.Close()

	var resultSlice []*Stockcollection
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice stockcollection")
	}

	if len(stockcollectionAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}
	if singular {
		object.R.Stockcollections = resultSlice
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ContactID == foreign.ContactID.Int {
				local.R.Stockcollections = append(local.R.Stockcollections, foreign)
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:67,代码来源:contact.go


示例4: LoadDbxref

// LoadDbxref allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (cvtermDbxrefL) LoadDbxref(e boil.Executor, singular bool, maybeCvtermDbxref interface{}) error {
	var slice []*CvtermDbxref
	var object *CvtermDbxref

	count := 1
	if singular {
		object = maybeCvtermDbxref.(*CvtermDbxref)
	} else {
		slice = *maybeCvtermDbxref.(*CvtermDbxrefSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &cvtermDbxrefR{}
		args[0] = object.DbxrefID
	} else {
		for i, obj := range slice {
			obj.R = &cvtermDbxrefR{}
			args[i] = obj.DbxrefID
		}
	}

	query := fmt.Sprintf(
		"select * from \"dbxref\" where \"dbxref_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Dbxref")
	}
	defer results.Close()

	var resultSlice []*Dbxref
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Dbxref")
	}

	if len(cvtermDbxrefAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.Dbxref = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.DbxrefID == foreign.DbxrefID {
				local.R.Dbxref = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:cvterm_dbxref.go


示例5: LoadStockcollectionprop

// LoadStockcollectionprop allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (stockcollectionL) LoadStockcollectionprop(e boil.Executor, singular bool, maybeStockcollection interface{}) error {
	var slice []*Stockcollection
	var object *Stockcollection

	count := 1
	if singular {
		object = maybeStockcollection.(*Stockcollection)
	} else {
		slice = *maybeStockcollection.(*StockcollectionSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &stockcollectionR{}
		args[0] = object.StockcollectionID
	} else {
		for i, obj := range slice {
			obj.R = &stockcollectionR{}
			args[i] = obj.StockcollectionID
		}
	}

	query := fmt.Sprintf(
		"select * from \"stockcollectionprop\" where \"stockcollection_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Stockcollectionprop")
	}
	defer results.Close()

	var resultSlice []*Stockcollectionprop
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Stockcollectionprop")
	}

	if len(stockcollectionAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.Stockcollectionprop = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.StockcollectionID == foreign.StockcollectionID {
				local.R.Stockcollectionprop = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:stockcollection.go


示例6: LoadThumbnails

// LoadThumbnails allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (fileL) LoadThumbnails(e boil.Executor, singular bool, maybeFile interface{}) error {
	var slice []*File
	var object *File

	count := 1
	if singular {
		object = maybeFile.(*File)
	} else {
		slice = *maybeFile.(*FileSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &fileR{}
		args[0] = object.ID
	} else {
		for i, obj := range slice {
			obj.R = &fileR{}
			args[i] = obj.ID
		}
	}

	query := fmt.Sprintf(
		"select * from \"thumbnails\" where \"file_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)
	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load thumbnails")
	}
	defer results.Close()

	var resultSlice []*Thumbnail
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice thumbnails")
	}

	if len(thumbnailAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}
	if singular {
		object.R.Thumbnails = resultSlice
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.ID == foreign.FileID {
				local.R.Thumbnails = append(local.R.Thumbnails, foreign)
				break
			}
		}
	}

	return nil
}
开发者ID:zqzca,项目名称:back,代码行数:67,代码来源:files.go


示例7: LoadType

// LoadType allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (pubRelationshipL) LoadType(e boil.Executor, singular bool, maybePubRelationship interface{}) error {
	var slice []*PubRelationship
	var object *PubRelationship

	count := 1
	if singular {
		object = maybePubRelationship.(*PubRelationship)
	} else {
		slice = *maybePubRelationship.(*PubRelationshipSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &pubRelationshipR{}
		args[0] = object.TypeID
	} else {
		for i, obj := range slice {
			obj.R = &pubRelationshipR{}
			args[i] = obj.TypeID
		}
	}

	query := fmt.Sprintf(
		"select * from \"cvterm\" where \"cvterm_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Cvterm")
	}
	defer results.Close()

	var resultSlice []*Cvterm
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Cvterm")
	}

	if len(pubRelationshipAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.Type = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.TypeID == foreign.CvtermID {
				local.R.Type = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:pub_relationship.go


示例8: LoadEnvironment

// LoadEnvironment allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (phenstatementL) LoadEnvironment(e boil.Executor, singular bool, maybePhenstatement interface{}) error {
	var slice []*Phenstatement
	var object *Phenstatement

	count := 1
	if singular {
		object = maybePhenstatement.(*Phenstatement)
	} else {
		slice = *maybePhenstatement.(*PhenstatementSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &phenstatementR{}
		args[0] = object.EnvironmentID
	} else {
		for i, obj := range slice {
			obj.R = &phenstatementR{}
			args[i] = obj.EnvironmentID
		}
	}

	query := fmt.Sprintf(
		"select * from \"environment\" where \"environment_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load Environment")
	}
	defer results.Close()

	var resultSlice []*Environment
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice Environment")
	}

	if len(phenstatementAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.Environment = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.EnvironmentID == foreign.EnvironmentID {
				local.R.Environment = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:phenstatement.go


示例9: LoadJbrowseTrack

// LoadJbrowseTrack allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (jbrowseOrganismL) LoadJbrowseTrack(e boil.Executor, singular bool, maybeJbrowseOrganism interface{}) error {
	var slice []*JbrowseOrganism
	var object *JbrowseOrganism

	count := 1
	if singular {
		object = maybeJbrowseOrganism.(*JbrowseOrganism)
	} else {
		slice = *maybeJbrowseOrganism.(*JbrowseOrganismSlice)
		count = len(slice)
	}

	args := make([]interface{}, count)
	if singular {
		object.R = &jbrowseOrganismR{}
		args[0] = object.JbrowseOrganismID
	} else {
		for i, obj := range slice {
			obj.R = &jbrowseOrganismR{}
			args[i] = obj.JbrowseOrganismID
		}
	}

	query := fmt.Sprintf(
		"select * from \"jbrowse_track\" where \"jbrowse_organism_id\" in (%s)",
		strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
	)

	if boil.DebugMode {
		fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
	}

	results, err := e.Query(query, args...)
	if err != nil {
		return errors.Wrap(err, "failed to eager load JbrowseTrack")
	}
	defer results.Close()

	var resultSlice []*JbrowseTrack
	if err = queries.Bind(results, &resultSlice); err != nil {
		return errors.Wrap(err, "failed to bind eager loaded slice JbrowseTrack")
	}

	if len(jbrowseOrganismAfterSelectHooks) != 0 {
		for _, obj := range resultSlice {
			if err := obj.doAfterSelectHooks(e); err != nil {
				return err
			}
		}
	}

	if singular && len(resultSlice) != 0 {
		object.R.JbrowseTrack = resultSlice[0]
		return nil
	}

	for _, foreign := range resultSlice {
		for _, local := range slice {
			if local.JbrowseOrganismID == foreign.JbrowseOrganismID {
				local.R.JbrowseTrack = foreign
				break
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:69,代码来源:jbrowse_organism.go



注:本文中的github.com/vattle/sqlboiler/queries.Bind函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang queries.BindMapping函数代码示例发布时间:2022-05-28
下一篇:
Golang boil.Executor类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap