dbmodel

package module
v0.0.0-...-09b74d4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contribution

type Contribution struct {
	ContributionID string
	UserAgent      string
	Distance       int
	TimeStampStart time.Time
	TimeStampStop  time.Time
	Duration       int
	PointsGeom     *geo.Path
	PointsTime     []time.Time
}

Contribution : Struct to respresent a contribution object from the database

type Database

type Database struct {
	PostgresHost       string
	PostgresUser       string
	PostgresPassword   string
	PostgresPort       int64
	PostgresDb         string
	PostgresRequireSSL string
}

Database : Struct to hold the database connection

func (Database) AddContribution

func (db Database) AddContribution(contribution *Contribution, user *User) (err error)

AddContribution : Create new user contribution

func (Database) AddUser

func (db Database) AddUser(user *User) (newUser User, err error)

AddUser : Create new user in the database

func (Database) FetchNewUsers

func (db Database) FetchNewUsers() (users []User, err error)

FetchNewUsers : Fetch an array of new users that have not yet fetched their old data

func (Database) GetExpiringUsers

func (db Database) GetExpiringUsers() (users []User, err error)

GetExpiringUsers : Get users which are expiring within half an hour

func (Database) GetUserData

func (db Database) GetUserData(userID string) (usr User, err error)

GetUserData : Request a user token for the ID

func (Database) UpdateUser

func (db Database) UpdateUser(user *User) (err error)

UpdateUser : Update an existing user

func (Database) VerifyConnection

func (db Database) VerifyConnection() (err error)

VerifyConnection : Connect to Postgres

type User

type User struct {
	ID                string
	UserIdentifier    string
	Provider          string
	ProviderUser      string
	AccessToken       string
	RefreshToken      string
	TokenCreationDate time.Time
	ExpiresAt         int
	ExpiresIn         int
	IsHistoryFetched  bool
}

User : Struct to respresent a user object from the database

type UserContribution

type UserContribution struct {
	UserContributionID string
	UserID             string
	ContributionID     string
}

UserContribution : Struct to respresent a UserContribution object from the database

Jump to

Keyboard shortcuts

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