Documentation ¶
Index ¶
- type Entry
- type Server
- func (s *Server) AddEntry(entry Entry) error
- func (s *Server) AddUser(user User) error
- func (s *Server) GetEntries(id string) (*[]Entry, error)
- func (s *Server) GetUser(id string) (*User, error)
- func (s *Server) GetUsersInTimezone(tz int) (*map[*User]int, error)
- func (s *Server) SumCalories(id string) (int, error)
- func (s *Server) UpdateUserTimezone(user User) error
- type ServerLayer
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct { ID string `json:"fuser_id"` Time int64 `json:"time"` Item string `json:"item"` Calories int `json:"calories"` }
Entry : Describes an entry in our "Entries" table
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server : Contains the app's database and offers an interface to interact with it.
func (*Server) GetEntries ¶
GetEntries : return a list of entries from a Users table
func (*Server) GetUsersInTimezone ¶
GetUsersInTimezone : return all users in given timezone Returns a map with Users as keys and their total event calories as values Example usage:
users, _ := b.server.GetUsersInTimezone(-8) for u, v := range *users { // do things }
func (*Server) SumCalories ¶
SumCalories : return sum of calories from entries for specific user Example usage:
calories, _ := b.server.SumCalories(c.facebookID) log.Print(strconv.Itoa(calories))
func (*Server) UpdateUserTimezone ¶
UpdateUserTimezone updates the timezone value of the given user
type ServerLayer ¶
type ServerLayer interface { AddUser(User) error AddEntry(Entry) error GetUser(string) (*User, error) GetUsersInTimezone(int) (*map[*User]int, error) GetEntries(string) (*[]Entry, error) SumCalories(string) (int, error) UpdateUserTimezone(User) error }
ServerLayer : Interface to interact with database
Click to show internal directories.
Click to hide internal directories.