Documentation ¶
Index ¶
- type AuthorizedUser
- type AuthorizingUser
- type PGDB
- func (s *PGDB) AuthorizedUser(accessToken string) (*types.AuthorizedUser, error)
- func (s *PGDB) AuthorizingUser(id string) (*types.AuthorizingUser, error)
- func (s *PGDB) InsertAuhorizingUser(authorizing *types.AuthorizingUser) error
- func (s *PGDB) UpsertAuthorizedUser(authorized *types.AuthorizedUser) error
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 ¶
PGDB implements the fitbit.Storage interface
func NewPGDB ¶
func NewPGDB() *PGDB
NewPGDB creates a new connection to a PostgreSQL server using the following environment variables: - DB_USER - DB_PASS - DB_NAME Loaded from a `.env` file, if present.
It 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) InsertAuhorizingUser ¶
func (s *PGDB) InsertAuhorizingUser(authorizing *types.AuthorizingUser) error
InsertAuhorizingUser 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.