3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 20:09:41 +01:00

Make some helper functions private.

This commit is contained in:
Jeremy Latt 2013-06-02 16:52:49 -07:00
parent 4e04230808
commit 74aaf2f9d3

View File

@ -93,7 +93,7 @@ func Save(db *sql.DB, s Savable) {
// general purpose sql // general purpose sql
// //
func FindId(q Queryable, sql string, args ...interface{}) (rowId RowId, err error) { func findId(q Queryable, sql string, args ...interface{}) (rowId RowId, err error) {
row := q.QueryRow(sql, args...) row := q.QueryRow(sql, args...)
err = row.Scan(&rowId) err = row.Scan(&rowId)
return return
@ -149,7 +149,7 @@ func FindUserByNick(q Queryable, nick string) (ur *UserRow, err error) {
} }
func FindUserIdByNick(q Queryable, nick string) (RowId, error) { func FindUserIdByNick(q Queryable, nick string) (RowId, error) {
return FindId(q, "SELECT id FROM user WHERE nick = ?", nick) return findId(q, "SELECT id FROM user WHERE nick = ?", nick)
} }
func FindChannelByName(q Queryable, name string) (cr *ChannelRow) { func FindChannelByName(q Queryable, name string) (cr *ChannelRow) {
@ -197,11 +197,9 @@ func InsertUserChannels(q Queryable, userId RowId, channelIds []RowId) (err erro
vals := strings.Repeat("(?, ?), ", len(channelIds)) vals := strings.Repeat("(?, ?), ", len(channelIds))
vals = vals[0 : len(vals)-2] vals = vals[0 : len(vals)-2]
args := make([]RowId, 2*len(channelIds)) args := make([]RowId, 2*len(channelIds))
var i = 0 for i, channelId := range channelIds {
for _, channelId := range channelIds {
args[i] = userId args[i] = userId
args[i+1] = channelId args[i+1] = channelId
i += 2
} }
_, err = q.Exec(ins+vals, args) _, err = q.Exec(ins+vals, args)
return return
@ -210,7 +208,7 @@ func InsertUserChannels(q Queryable, userId RowId, channelIds []RowId) (err erro
// channel // channel
func FindChannelIdByName(q Queryable, name string) (RowId, error) { func FindChannelIdByName(q Queryable, name string) (RowId, error) {
return FindId(q, "SELECT id FROM channel WHERE name = ?", name) return findId(q, "SELECT id FROM channel WHERE name = ?", name)
} }
func FindChannelsForUser(q Queryable, userId RowId) (crs []*ChannelRow, err error) { func FindChannelsForUser(q Queryable, userId RowId) (crs []*ChannelRow, err error) {