示例#1
0
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
0
文件: account.go 项目: joho/firesize
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
0
文件: db.go 项目: sisteamnik/guseful
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
0
文件: db.go 项目: sisteamnik/guseful
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
}
示例#5
0
文件: db.go 项目: sisteamnik/guseful
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
}
示例#6
0
文件: db.go 项目: sisteamnik/guseful
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
}
示例#7
0
func upd(db *gorp.Transaction, r RateLimit) error {
	r.Updated = time.Now().UnixNano()
	_, err := db.Update(&r)
	return err
}
示例#8
0
func setTry(db *gorp.Transaction, r RateLimit) error {
	r.Updated = time.Now().UnixNano()
	r.Count++
	_, err := db.Update(&r)
	return err
}