本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}