本文整理汇总了Golang中github.com/coopernurse/gorp.Transaction.Select方法的典型用法代码示例。如果您正苦于以下问题:Golang Transaction.Select方法的具体用法?Golang Transaction.Select怎么用?Golang Transaction.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coopernurse/gorp.Transaction
的用法示例。
在下文中一共展示了Transaction.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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)
}
示例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)))
}
示例4: 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
}