Documentation ¶
Index ¶
- type Storage
- func (s Storage) AddCity(cityName string, stateName string) int64
- func (s Storage) AddGmapsPlace(g adder.GmapsPlace) int64
- func (s Storage) AddRestaurant(r adder.Restaurant) int64
- func (s Storage) AddUser(u adder.User) int64
- func (s Storage) AddVisit(v adder.Visit) int64
- func (s Storage) AddVisitUser(vu adder.VisitUser) int64
- func (s *Storage) Begin()
- func (s Storage) CloseStorage()
- func (s Storage) Commit()
- func (s Storage) GetCityIDByNameAndState(cityName string, stateName string) int64
- func (s Storage) GetDistinct(columnName string, tableName string) []string
- func (s Storage) GetRestaurant(id int64) lister.Restaurant
- func (s Storage) GetRestaurantAvgRatingByUser(restaurantID int64) []lister.AvgUserRating
- func (s Storage) GetRestaurants(sortOps []lister.SortOperation, filterOps []lister.FilterOperation) []lister.Restaurant
- func (s Storage) GetRestaurantsByCity(cityID int64) []lister.Restaurant
- func (s Storage) GetUser(id int64) lister.User
- func (s Storage) GetUserAuthByEmail(email string) auther.User
- func (s Storage) GetUserAuthByID(id int64) auther.User
- func (s Storage) GetUserBy(field string, value string) lister.User
- func (s Storage) GetUserCount() int64
- func (s Storage) GetUsers() []lister.User
- func (s Storage) GetVisit(id int64, resID int64) lister.Visit
- func (s Storage) GetVisitUsersByVisitID(visitID int64) []lister.VisitUser
- func (s Storage) GetVisitsByRestaurantID(restaurantID int64, sortOps []lister.SortOperation) []lister.Visit
- func (s Storage) IsDuplicateRestaurant(r adder.Restaurant) bool
- func (s Storage) RemoveCity(cityID int64) int64
- func (s Storage) RemoveGmapsPlace(gmapsID int64) int64
- func (s Storage) RemoveRestaurant(r remover.Restaurant) int64
- func (s Storage) RemoveVisit(visitID int64) int64
- func (s Storage) RemoveVisitUser(visitUserID int64) int64
- func (s Storage) RestaurantFilterFields() map[string]lister.Field
- func (s Storage) RestaurantSortFields() map[string]string
- func (s Storage) Rollback()
- func (s Storage) UpdateGmapsPlace(gp updater.GmapsPlace) int64
- func (s Storage) UpdateRestaurant(r updater.Restaurant) int64
- func (s Storage) UpdateUser(u updater.User) int64
- func (s Storage) UpdateUserPassword(id int64, newPasswordHash string) int64
- func (s Storage) UpdateUserRememberToken(u auther.User) int64
- func (s Storage) UpdateVisit(v updater.Visit) int64
- func (s Storage) UpdateVisitUser(vu updater.VisitUser) int64
- func (s Storage) VisitSortFields() map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage stores restaurant data in a sqlite3 database
func NewStorage ¶
NewStorage returns a new database/sql instance initialized with sqlite3
func (Storage) AddCity ¶
AddCity adds a city to the city table and returns the primary key id. Must call Commit() to commit transaction
func (Storage) AddGmapsPlace ¶
func (s Storage) AddGmapsPlace(g adder.GmapsPlace) int64
AddGmapsPlace adds a Google Maps Place to the database and returns the primary key id. Must call Commit() to commit the transaction
func (Storage) AddRestaurant ¶
func (s Storage) AddRestaurant(r adder.Restaurant) int64
AddRestaurant adds the given restaurant to the sqlite database. Must call Commit() to commit transaction
func (Storage) AddUser ¶ added in v1.0.0
AddUser adds a given user to the database and returns the new user id. Caller must call Commit() to commit the transaction.
func (Storage) AddVisit ¶
AddVisit adds the given visit to the sqlite database. Must call Commit() to commit transaction
func (Storage) AddVisitUser ¶
AddVisitUser adds the given visit to the sqlite database. Must call Commit() to commit transaction
func (Storage) CloseStorage ¶
func (s Storage) CloseStorage()
CloseStorage closes the database by calling db.Close()
func (Storage) GetCityIDByNameAndState ¶
GetCityIDByNameAndState queries the database for a given city name and state name, returns the id of the row if it exists
func (Storage) GetDistinct ¶ added in v1.0.0
GetDistinct returns a list of distinct values for a given column from a given table
func (Storage) GetRestaurant ¶
func (s Storage) GetRestaurant(id int64) lister.Restaurant
GetRestaurant queries the restaurant table for the given id. If the returned restaurant has ID = 0 then it is not in the database
func (Storage) GetRestaurantAvgRatingByUser ¶ added in v1.0.0
func (s Storage) GetRestaurantAvgRatingByUser(restaurantID int64) []lister.AvgUserRating
GetRestaurantAvgRatingByUser gets a given restaurants average rating group by user. If the returned value for a user is 0 then the restaurant has no ratings for that user.
func (Storage) GetRestaurants ¶
func (s Storage) GetRestaurants(sortOps []lister.SortOperation, filterOps []lister.FilterOperation) []lister.Restaurant
GetRestaurants queries the restaurant table for all restaurants.
func (Storage) GetRestaurantsByCity ¶
func (s Storage) GetRestaurantsByCity(cityID int64) []lister.Restaurant
GetRestaurantsByCity gives you all the restaurants with a given city id.
func (Storage) GetUser ¶
GetUser queries the user table for a given user id. If the returned user has ID = 0 then it is not in the db.
func (Storage) GetUserAuthByEmail ¶ added in v1.0.0
GetUserAuthByEmail returns the password and remember hashes of a given email. If the returned user has ID = 0 then it is not in the db.
func (Storage) GetUserAuthByID ¶ added in v1.0.0
GetUserAuthByID returns the password and remember hashes of a given email. If the returned user has ID = 0 then it is not in the db.
func (Storage) GetUserBy ¶ added in v1.0.0
GetUserBy queries the user table for a given user by field and value. Do not pass field arguments from untrusted sources. If the returned user has ID = 0 then it is not in the db.
func (Storage) GetUserCount ¶ added in v1.0.0
GetUserCount returns the number of users in the db.
func (Storage) GetVisit ¶
GetVisit queries the visit table for a given visit id and restaurant id. If the returned visit has ID = 0 then it is not in the database
func (Storage) GetVisitUsersByVisitID ¶
GetVisitUsersByVisitID queries the db for user for the given visit_id
func (Storage) GetVisitsByRestaurantID ¶
func (s Storage) GetVisitsByRestaurantID(restaurantID int64, sortOps []lister.SortOperation) []lister.Visit
GetVisitsByRestaurantID gets all the visits for a given restaurant_id
func (Storage) IsDuplicateRestaurant ¶
func (s Storage) IsDuplicateRestaurant(r adder.Restaurant) bool
IsDuplicateRestaurant returns true if the database already has a restaurant with the same name in the same city and state
func (Storage) RemoveCity ¶
RemoveCity deletes a given city and returns the number of rows affected. Caller must call Commit() to commit the transaction
func (Storage) RemoveGmapsPlace ¶ added in v1.0.0
func (Storage) RemoveRestaurant ¶
func (s Storage) RemoveRestaurant(r remover.Restaurant) int64
RemoveRestaurant deletes a given restaurant from the database and returns the rows affected. Caller must call Commit() to commit the transaction
func (Storage) RemoveVisit ¶
RemoveVisit deletes a given visit and returns the number of rows affected. Caller must call Commit() to commit the transaction
func (Storage) RemoveVisitUser ¶
RemoveVisitUser deletes a given visit_user and returns the number of rows affected. Caller must call Commit() to commit the transaction
func (Storage) RestaurantFilterFields ¶ added in v1.0.0
func (Storage) RestaurantSortFields ¶ added in v1.0.0
func (Storage) UpdateGmapsPlace ¶
func (s Storage) UpdateGmapsPlace(gp updater.GmapsPlace) int64
UpdateGmapsPlace updates a given gmaps_place, returns the rows affected. Caller must call Commit() to commit the transaction
func (Storage) UpdateRestaurant ¶
func (s Storage) UpdateRestaurant(r updater.Restaurant) int64
UpdateRestaurant updates a given restaurant, returns the rows affected. Must call Commit() to commit transaction
func (Storage) UpdateUser ¶ added in v1.0.0
UpdateUser updates a given user, returns the rows affected. Caller must call Commit() to commit the transaction
func (Storage) UpdateUserPassword ¶ added in v1.0.0
UpdateUserPassword updates the password of the user with the given id. Caller must call Commit() to commit the transaction
func (Storage) UpdateUserRememberToken ¶ added in v1.0.0
UpdateUserRememberToken updates a user's remember_hash and then returns the number of rows affected. Caller must call Commit() to commit the transaction.
func (Storage) UpdateVisit ¶
UpdateVisit updates a given visit, returns the rows affected. Caller must call Commit() to commit the transaction
func (Storage) UpdateVisitUser ¶
UpdateVisitUser updates a given visit_user, returns the rows affected. Caller must call Commit() to commit the transaction