postgres

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

package postgresql implements the database layer for postgresql

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewDBConnection

func NewDBConnection(conn Queryer) *Connection

func (*Connection) DestroySession

func (d *Connection) DestroySession(ctx context.Context, sessionID ccc.UUID) error

func (*Connection) DestroySessionOIDC

func (d *Connection) DestroySessionOIDC(ctx context.Context, oidcSID string) error

DestroySessionOIDC marks the session as expired

func (*Connection) InsertSession

func (d *Connection) InsertSession(ctx context.Context, session *InsertSession) (ccc.UUID, error)

InsertSession inserts Session into database

func (*Connection) Session

func (d *Connection) Session(ctx context.Context, sessionID ccc.UUID) (*Session, error)

Session returns the session information from the database for given sessionID

func (*Connection) UpdateSessionActivity

func (d *Connection) UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

UpdateSessionActivity updates the session activity column with the current time

type DB

type DB interface {
	// Session returns the session information from the database for given sessionID.
	Session(ctx context.Context, sessionID ccc.UUID) (*Session, error)

	// InsertSession inserts Session into database.
	InsertSession(ctx context.Context, sessionInfo *InsertSession) (ccc.UUID, error)

	// UpdateSessionActivity updates the session activity column with the current time.
	UpdateSessionActivity(ctx context.Context, sessionID ccc.UUID) error

	// DestroySession marks the session as expired.
	DestroySession(ctx context.Context, sessionID ccc.UUID) error

	// DestroySessionOIDC marks the session as expired
	DestroySessionOIDC(ctx context.Context, oidcSID string) error
}

type InsertSession

type InsertSession struct {
	OidcSID   string    `db:"OidcSid"`
	Username  string    `db:"Username"`
	CreatedAt time.Time `db:"CreatedAt"`
	UpdatedAt time.Time `db:"UpdatedAt"`
	Expired   bool      `db:"Expired"`
}

type Queryer

type Queryer interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) pgx.Row
	Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
}

type Session

type Session struct {
	ID        ccc.UUID  `db:"Id"`
	OidcSID   string    `db:"OidcSid"`
	Username  string    `db:"Username"`
	CreatedAt time.Time `db:"CreatedAt"`
	UpdatedAt time.Time `db:"UpdatedAt"`
	Expired   bool      `db:"Expired"`
}

Jump to

Keyboard shortcuts

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