本文整理汇总了Golang中github.com/coopernurse/gorp.Transaction类的典型用法代码示例。如果您正苦于以下问题:Golang Transaction类的具体用法?Golang Transaction怎么用?Golang Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transaction类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetCommentsForType
func GetCommentsForType(db *gorp.Transaction, itemtype string) ([]Comment,
error) {
var cs []Comment
_, err := db.Select(&cs, "select * from Comment where"+
" ItemType = ? and Deleted = 0 order by Id desc",
itemtype)
return cs, err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:8,代码来源:comments.go
示例2: FindAccountByEmail
func FindAccountByEmail(txn *gorp.Transaction, email string) *Account {
accounts, err := txn.Select(Account{}, `select * from accounts where lower(email) = lower($1) limit 1`, email)
if err != nil {
panic(err)
}
if len(accounts) == 0 {
return nil
}
return accounts[0].(*Account)
}
开发者ID:joho,项目名称:firesize,代码行数:10,代码来源:account.go
示例3: getVotes
func getVotes(db *gorp.Transaction, gid, fid int64) (rate.Rate, error) {
r := []rate.Rate{}
_, err := db.Select(&r, "select * from Rate where ItemId = ? and ItemType = ?", gid, fid)
if err != nil {
return rate.Rate{}, err
}
if len(r) == 1 {
r[0].Votes, err = getVotesforRate(db, r[0].Id)
if err != nil {
return rate.Rate{}, err
}
return r[0], nil
}
return rate.Rate{}, errors.New(fmt.Sprint("Unexpected error", len(r)))
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:15,代码来源:db.go
示例4: createRate
func createRate(db *gorp.Transaction, guruid int64) error {
humor := rate.Rate{
ItemType: 0,
ItemId: guruid,
}
goodwill := rate.Rate{
ItemType: 1,
ItemId: guruid,
}
understandability := rate.Rate{
ItemType: 2,
ItemId: guruid,
}
err := db.Insert(&humor, &goodwill, &understandability)
return err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:16,代码来源:db.go
示例5: createFeatures
func createFeatures(db *gorp.Transaction, guruid int64) error {
humor := GuruFeatures{
Feature: "humor",
GuruId: guruid,
}
goodwill := GuruFeatures{
Feature: "goodwill",
GuruId: guruid,
}
understandability := GuruFeatures{
Feature: "understandability",
GuruId: guruid,
}
err := db.Insert(&humor, &goodwill, &understandability)
return err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:16,代码来源:db.go
示例6: getVotesforRate
func getVotesforRate(db *gorp.Transaction, rateid int64) ([]rate.Vote, error) {
r := []rate.Vote{}
_, err := db.Select(&r, "select * from Vote where RateId = ?", rateid)
return r, err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:5,代码来源:db.go
示例7: upd
func upd(db *gorp.Transaction, r RateLimit) error {
r.Updated = time.Now().UnixNano()
_, err := db.Update(&r)
return err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:5,代码来源:ratelimit.go
示例8: setTry
func setTry(db *gorp.Transaction, r RateLimit) error {
r.Updated = time.Now().UnixNano()
r.Count++
_, err := db.Update(&r)
return err
}
开发者ID:sisteamnik,项目名称:guseful,代码行数:6,代码来源:ratelimit.go
注:本文中的github.com/coopernurse/gorp.Transaction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论