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