fitbit_pgdb

package module
v3.0.0-...-70d2b49 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

README

Fitbit PostgreSQL storage

This package contains an implementation of the fitbit.Storage interface for the Fitbit Web API - Go client package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizedUser

type AuthorizedUser struct {
	types.AuthorizedUser
	ID        int64     `igor:"primary_key"`
	CreatedAt time.Time `sql:"default:now()"`
}

AuthorizedUser wraps fitbit types.AuthorizedUser and adds: - The igor-required method TableName() - The primary key - The created at field

func (AuthorizedUser) TableName

func (AuthorizedUser) TableName() string

type AuthorizingUser

type AuthorizingUser struct {
	types.AuthorizingUser
	ID        int64     `igor:"primary_key"`
	CreatedAt time.Time `sql:"default:now()"`
}

AuthorizingUser wraps fitbit types.AuthorizingUser and adds: - The igor-required method TableName() - The primary key - The created at field

func (AuthorizingUser) TableName

func (AuthorizingUser) TableName() string

type PGDB

type PGDB struct {
	*igor.Database
}

PGDB implements the fitbit.Storage interface

func NewPGDB

func NewPGDB(connectionString string) *PGDB

NewPGDB creates a new connection to a PostgreSQL server. You must provide the connection string to use for connecting to a running PostgreSQL instance.

*PGDB implements the `fitbit.Storage` interface.

func NewPGDBFromConnection

func NewPGDBFromConnection(connection *sql.DB) *PGDB

NewPGDBFromConnection creates a new instance of PGDB without creating a new connection. It re-uses the database connection provided as input.

*PGDB implements the `fitbit.Storage` interface.

func (*PGDB) AuthorizedUser

func (s *PGDB) AuthorizedUser(accessToken string) (*types.AuthorizedUser, error)

AuthorizedUser executes a SELECT for the types.AuthorizedUser using the `accessToken` as only query parameter. NOTE: the `accessToken` is unique on the underlying table.

func (*PGDB) AuthorizingUser

func (s *PGDB) AuthorizingUser(id string) (*types.AuthorizingUser, error)

AuthorizingUser executes a SELECT for the types.AuthorizingUser using the `id` provided as PRIMARY KEY for creating the query.

func (*PGDB) InsertAuthorizingUser

func (s *PGDB) InsertAuthorizingUser(authorizing *types.AuthorizingUser) error

InsertAuthorizingUser executes a CREATE query on the PostgreSQL database inserting the authorizing user in the associated table.

func (*PGDB) UpsertAuthorizedUser

func (s *PGDB) UpsertAuthorizedUser(authorized *types.AuthorizedUser) error

UpsertAuthorizedUser executes INSERT or UPDATE the user on the PostgreSQL database. It inserts the user if the SELECT by user UserID fields returns the empty set. If it finds the user insteads it updates all the other NON PRIMARY KEY (or equivalent like UserID) fields.

Jump to

Keyboard shortcuts

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