当前位置: 首页>>代码示例>>Golang>>正文


Golang Tx.Rebind方法代码示例

本文整理汇总了Golang中github.com/jmoiron/sqlx.Tx.Rebind方法的典型用法代码示例。如果您正苦于以下问题:Golang Tx.Rebind方法的具体用法?Golang Tx.Rebind怎么用?Golang Tx.Rebind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jmoiron/sqlx.Tx的用法示例。


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

示例1: buildsFindByRepoSha

// buildsFindByRepoSha finds a build by repository and sha.
func buildsFindByRepoSha(tx *sqlx.Tx, repoSha string) (*Build, error) {
	parts := strings.Split(repoSha, "@")
	var sql = `SELECT * FROM builds
WHERE repository = ?
AND sha = ?
ORDER BY seq desc
LIMIT 1`
	var b Build
	err := tx.Get(&b, tx.Rebind(sql), parts[0], parts[1])
	return &b, err
}
开发者ID:atmos,项目名称:conveyor,代码行数:12,代码来源:builds.go

示例2: artifactsFindByRepoSha

// artifactsFindByRepoSha finds an artifact by image.
func artifactsFindByRepoSha(tx *sqlx.Tx, repoSha string) (*Artifact, error) {
	parts := strings.Split(repoSha, "@")
	var sql = `SELECT * FROM artifacts
WHERE repository = ?
AND sha = ?
ORDER BY seq desc
LIMIT 1`
	var a Artifact
	err := tx.Get(&a, tx.Rebind(sql), parts[0], parts[1])
	return &a, err
}
开发者ID:atmos,项目名称:conveyor,代码行数:12,代码来源:artifacts.go

示例3: buildsUpdateState

// buildsUpdateState changes the state of a build.
func buildsUpdateState(tx *sqlx.Tx, buildID string, state BuildState) error {
	var sql string
	switch state {
	case StateBuilding:
		sql = `UPDATE builds SET state = ?, started_at = ? WHERE id = ?`
	case StateSucceeded, StateFailed:
		sql = `UPDATE builds SET state = ?, completed_at = ? WHERE id = ?`
	default:
		panic(fmt.Sprintf("not implemented for %s", state))
	}

	_, err := tx.Exec(tx.Rebind(sql), state, time.Now(), buildID)
	return err
}
开发者ID:atmos,项目名称:conveyor,代码行数:15,代码来源:builds.go

示例4: buildsFind

// buildsFind finds a build by ID.
func buildsFind(tx *sqlx.Tx, buildID string) (*Build, error) {
	const (
		findBuildSql     = `SELECT * FROM builds where id = ?`
		findArtifactsSql = `SELECT image FROM artifacts WHERE build_id = ?`
	)

	var b Build
	err := tx.Get(&b, tx.Rebind(findBuildSql), buildID)
	if err != nil {
		return nil, err
	}

	err = tx.Select(&b.Artifacts, tx.Rebind(findArtifactsSql), buildID)
	if err != nil {
		return nil, err
	}

	return &b, err
}
开发者ID:emmetog,项目名称:conveyor,代码行数:20,代码来源:builds.go

示例5: buildsFindByID

// buildsFindByID finds a build by ID.
func buildsFindByID(tx *sqlx.Tx, buildID string) (*Build, error) {
	const findBuildSql = `SELECT * FROM builds WHERE id = ? LIMIT 1`
	var b Build
	err := tx.Get(&b, tx.Rebind(findBuildSql), buildID)
	return &b, err
}
开发者ID:atmos,项目名称:conveyor,代码行数:7,代码来源:builds.go

示例6: artifactsFindByID

// artifactsFindByID finds an artifact by ID.
func artifactsFindByID(tx *sqlx.Tx, artifactID string) (*Artifact, error) {
	var sql = `SELECT * FROM artifacts WHERE id = ? LIMIT 1`
	var a Artifact
	err := tx.Get(&a, tx.Rebind(sql), artifactID)
	return &a, err
}
开发者ID:atmos,项目名称:conveyor,代码行数:7,代码来源:artifacts.go


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