當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。