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 }
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) }
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))) }
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 }