當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gorp.Transaction類代碼示例

本文整理匯總了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;未經允許,請勿轉載。