db

package
v0.0.0-...-57dad53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	Name     string
	User     string
	Password string
}

Config provides the configuration for the database.

type Conn

type Conn struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Conn maintains a connection to the database.

func New

func New(cfg *Config) (*Conn, error)

New creates a new connection to the database and initializes it.

func (*Conn) Migrate

func (c *Conn) Migrate() error

Migrate performs all database migrations.

func (*Conn) Transaction

func (c *Conn) Transaction(fn func(*Conn) error) error

Transaction wraps the provided callback function in a database transaction.

type Exclusion

type Exclusion struct {
	ID             int64
	User           *User `gorm:"ForeignKey:UserID"`
	UserID         int64 `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
	ExcludedUser   *User `gorm:"ForeignKey:ExcludedUserID"`
	ExcludedUserID int64 `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
}

Exclusion represents a desire by a user to avoid being paired with another user.

type Match

type Match struct {
	ID       int64
	Pearup   *Pearup `gorm:"ForeignKey:PearupID"`
	PearupID int64   `sql:"type:int REFERENCES pearups(id) ON DELETE CASCADE"`
	User1    *User   `gorm:"ForeignKey:User1ID"`
	User1ID  int64   `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
	User2    *User   `gorm:"ForeignKey:User2ID"`
	User2ID  int64   `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
}

Match represents a pairing between two users.

type Pearup

type Pearup struct {
	ID         int64
	Name       string    `gorm:"not null"`
	EndDate    time.Time `gorm:"not null"`
	IsComplete bool      `gorm:"not null"`
	IsPublic   bool      `gorm:"not null"`
	CanRequest bool      `gorm:"not null" sql:"DEFAULT:FALSE"`
}

Pearup represents a single pearup.

type Registration

type Registration struct {
	ID       int64
	Pearup   *Pearup `gorm:"ForeignKey:PearupID"`
	PearupID int64   `sql:"type:int REFERENCES pearups(id) ON DELETE CASCADE"`
	User     *User   `gorm:"ForeignKey:UserID"`
	UserID   int64   `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
}

Registration represents an intent by a user to participate in a pearup.

type Request

type Request struct {
	ID              int64
	User            *User `gorm:"ForeignKey:UserID"`
	UserID          int64 `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
	RequestedUser   *User `gorm:"ForeignKey:RequestedUserID"`
	RequestedUserID int64 `sql:"type:int REFERENCES users(id) ON DELETE CASCADE"`
}

Request represents a desire by a user to be matched with a specific user.

type User

type User struct {
	ID int64

	// Each user authenticates with one or more of these services
	GoogleID   string `gorm:"not null"`
	FacebookID string `gorm:"not null"`

	// This data is filled in with the most recent login method
	Name    string `gorm:"not null"`
	Email   string `gorm:"not null"`
	Picture string `gorm:"not null"`

	// Management data
	IsAdmin bool `gorm:"not null"`

	// Profile data
	Link     string `gorm:"not null"`
	IsMale   bool   `gorm:"not null"`
	IsFemale bool   `gorm:"not null"`
}

User represents an authenticated Facebook user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL