Documentation ¶
Overview ¶
Package db implements DownToMeet server's connection to the PostgreSQL database. It also contains the database model definitions as GORM models.
Index ¶
- func Get(logger FieldLogger, dsn string) (*gorm.DB, error)
- func MeetupIDFromString(s string) (uint, error)
- func TagIDFromString(s string) (uint, error)
- func UserIDFromString(s string) (uint, error)
- type Coordinates
- type FieldLogger
- type Logger
- func (l Logger) Error(ctx context.Context, s string, i ...interface{})
- func (l Logger) Info(ctx context.Context, s string, i ...interface{})
- func (l Logger) LogMode(_ gormlogger.LogLevel) gormlogger.Interface
- func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l Logger) Warn(ctx context.Context, s string, i ...interface{})
- type Meetup
- type MeetupLocation
- type Tag
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(logger FieldLogger, dsn string) (*gorm.DB, error)
Get returns a new gorm.DB from the given Data Source Name (DSN) connection string.
func MeetupIDFromString ¶
MeetupIDFromString reverses Meetup.IDString.
func TagIDFromString ¶
TagIDFromString reverses Tag.IDString.
func UserIDFromString ¶
UserIDFromString reverses User.IDString.
Types ¶
type Coordinates ¶
type Coordinates struct {
Lat, Lon *float64
}
Coordinates represent WGS 84 coordinates of the earth. It is not a database model but rather stored as a part of MeetupLocation.
type FieldLogger ¶
FieldLogger is the same as log.FieldLogger, but with an additional WithContext method.
type Logger ¶
type Logger struct {
Logger FieldLogger
}
Logger is an adapter from logrus' logger to GORM.
func (Logger) LogMode ¶
func (l Logger) LogMode(_ gormlogger.LogLevel) gormlogger.Interface
LogMode implements GORM's logger.Interface and does nothing.
type Meetup ¶
type Meetup struct { gorm.Model Title string Time time.Time Description string Tags []*Tag `gorm:"many2many:meetup_tag;"` MaxCapacity int64 MinCapacity int64 Owner uint Attendees []*User `gorm:"many2many:meetup_user_attend;"` Location MeetupLocation `gorm:"embedded;embeddedPrefix:location_"` PendingAttendees []*User `gorm:"many2many:meetup_user_pending;"` RejectedAttendees []*User `gorm:"many2many:meetup_user_rejected;"` Cancelled bool }
Meetup is the database model for a meetup.
type MeetupLocation ¶
type MeetupLocation struct { Coordinates URL string Name string }
MeetupLocation represents where a meetup could be held. It is not a database model but rather stored as a part of Meetup.
type Tag ¶
type Tag struct { gorm.Model Name string `gorm:"uniqueIndex"` Users []*User `gorm:"many2many:tag_user;"` Meetups []*Meetup `gorm:"many2many:meetup_tag;"` }
Tag is the database model for tags.
type User ¶
type User struct { gorm.Model Email string `gorm:"uniqueIndex"` Name string ContactInfo string ProfilePic *string FacebookID *string `gorm:"uniqueIndex"` GoogleID *string `gorm:"uniqueIndex"` Location Coordinates `gorm:"embedded;embeddedPrefix:location_"` OwnedMeetups []*Meetup `gorm:"foreignKey:Owner"` Attending []*Meetup `gorm:"many2many:meetup_user_attend;"` Tags []*Tag `gorm:"many2many:tag_user;"` PendingApproval []*Meetup `gorm:"many2many:meetup_user_pending;"` }
User is the database model for users.