Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoMigrate ¶
func AutoMigrate()
AutoMigrate ensures the database is migrated to the latest schema
Types ¶
type DiscoverFilters ¶
DiscoverFilters that we can use in the GetUnswipedUsers function.
type Location ¶
type Location struct { Name string `json:"name"` Longitude float64 `json:"longitude"` Latitude float64 `json:"latitude"` }
Location is a struct that represents a high-level location
type User ¶
type User struct { ID int `json:"id" gorm:"primaryKey"` Name string `json:"name"` Email string `json:"email,omitempty" gorm:"unique"` Gender string `json:"gender"` Age int `json:"age"` Password string `json:"password,omitempty"` Location Location `json:"location" gorm:"embedded;embeddedPrefix:location_"` }
User is a struct that represents a high-level user
func CreateRandom ¶
CreateRandom creates a user with random data, returning the user as if you had called 'Create'.
func GetByEmail ¶
GetByEmail returns a user by their email
type UserWithDistance ¶
type UserWithDistance struct { User `json:",inline"` DistanceFromMe float64 `json:"distance_from_me,omitempty" gorm:"column:distance_in_km"` }
UserWithDistance is a struct that adds a distance field to the User struct
func GetUnswipedUsers ¶
func GetUnswipedUsers(userID int, filters DiscoverFilters) ([]UserWithDistance, error)
Get all users that the user hasn't swiped on. (Ensuring the user is not included in the results.)
func (UserWithDistance) TableName ¶
func (UserWithDistance) TableName() string
TableName is used to define the table name for the User struct in the database We want to continue using the 'users' table, as this struct just declares our calculated distance column.