postgres

package
v0.0.0-...-f54f16c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorp.DbMap
	*config.Postgres
}

Postgres is a wrapping struct that will hold the database mapping object from the underlying db/sql implementation (gorp) plus our service config specifically for storage.

Additionally this struct implements our storage.Client interface

func Connect

func Connect(dbConf *config.Postgres) (*DB, error)

Connect creates a new Postgres client, connects to the database server

func ConnectAndMigrate

func ConnectAndMigrate(dbConf *config.Postgres) (*DB, error)

ConnectAndMigrate creates a new Postgres client, connects to the database server and runs the migrations

func (*DB) DeleteUserSettings

func (db *DB) DeleteUserSettings(name string, connector string) error

func (*DB) DestructiveMigrateForTests

func (db *DB) DestructiveMigrateForTests() error

DestructiveMigrateForTests will: * Drop the database to give you a clean slate * Run all your migrations * Forcibly run all the migrations again to verify that they are idempotent.

Obviously you don't want this for production, but you should use it instead of the plain Migrate function in your tests if you can.

func (*DB) EmptyStorage

func (db *DB) EmptyStorage() error

EmptyStorage deletes all the data from the database @afiune This function is only used by our Integration Test framework

func (*DB) GetUserSettings

func (db *DB) GetUserSettings(name string, connector string) (*user_settings.GetUserSettingsResponse, error)

GetUserSettings retrieves user settings from the database

func (*DB) PutUserSettings

func (db *DB) PutUserSettings(name string, connector string,
	settings map[string]*user_settings.UserSettingValue) (*user_settings.PutUserSettingsResponse, error)

type UserSettings

type UserSettings struct {
	Id        int32           `db:"id, primarykey, autoincrement"`
	UserName  string          `db:"user_name"`
	Connector string          `db:"connector"`
	Settings  json.RawMessage `db:"settings"`
}

Jump to

Keyboard shortcuts

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