本文整理汇总了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
}