postgres

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTable

func CreateTable(db *sql.DB, tableName string) error

CreateTable creates the table that will persist the peers

func Migrate

func Migrate(db *sql.DB) error

func NewDB

func NewDB(dburl string) (*sql.DB, func(*sql.DB) error, error)

NewDB connects to postgres DB in the specified path

func WithDB

func WithDB(dburl string, migrate bool) persistence.DBOption

WithDB is a DBOption that lets you use a postgresql DBStore and run migrations

Types

type Queries

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

Queries are the postgresql queries for a given table.

func NewQueries

func NewQueries(tbl string, db *sql.DB) (*Queries, error)

NewQueries creates a new Postgresql set of queries for the passed table

func (Queries) Delete

func (q Queries) Delete() string

Delete returns the query for deleting a row.

func (Queries) Exists

func (q Queries) Exists() string

Exists returns the query for determining if a row exists.

func (Queries) Get

func (q Queries) Get() string

Get returns the query for getting a row.

func (Queries) GetSize

func (q Queries) GetSize() string

GetSize returns the query for determining the size of a value.

func (Queries) Limit

func (q Queries) Limit() string

Limit returns the query fragment for limiting results.

func (Queries) Offset

func (q Queries) Offset() string

Offset returns the query fragment for returning rows from a given offset.

func (Queries) Prefix

func (q Queries) Prefix() string

Prefix returns the query fragment for getting a rows with a key prefix.

func (Queries) Put

func (q Queries) Put() string

Put returns the query for putting a row.

func (Queries) Query

func (q Queries) Query() string

Query returns the query for getting multiple rows.

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

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