postgres

package
v0.0.0-...-e0b0cc7 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COLLECTION = "chathistory"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

Factory is initialized with the config file and then used to make client data objects of the appropriate type when clients are created.

func NewFactory

func NewFactory(databaseLogin, databasePassword, databaseName, databaseIP, databasePort string) (*Factory, error)

NewFactory creates a new clientdata factory using a postgres datastore.

func (*Factory) Create

func (cdf *Factory) Create(name string) clientdata.ClientData

Create returns a ClientData object of the type for the factory.

type InputAdd

type InputAdd struct {
	Username string            `bson:"Username" json:"Username"`
	Table    string            `bson:"Table" json:"Table"`
	Values   map[string]string `bson:"Values" json:"Values"`
}

type MongoDB

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

func NewMongoDB

func NewMongoDB(databaseLogin, databasePassword, databaseName, databaseIP, databasePort string) (*MongoDB, error)

func (*MongoDB) Add

func (p *MongoDB) Add(table string, values map[string]string) error

Add adds row values to mongoDB

func (*MongoDB) Delete

func (p *MongoDB) Delete(table string, values map[string]string) error

func (*MongoDB) Exists

func (p *MongoDB) Exists(table string, values map[string]string) (bool, error)

func (*MongoDB) Get

func (p *MongoDB) Get(table string, values map[string]string, columns ...string) ([]map[string]string, error)

func (*MongoDB) Set

func (p *MongoDB) Set(table string, values, cond map[string]string) error

type Postgres

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

Postgres is a type of datastore using a postgresql database.

func NewPostgres

func NewPostgres(databaseLogin, databasePassword, databaseName, databaseIP, databasePort string) (*Postgres, error)

NewPostgres sets up the connection to the database and returns a Postgres datastore.

func (*Postgres) Add

func (p *Postgres) Add(table string, values map[string]string) error

Add adds row values to table.

func (*Postgres) Delete

func (p *Postgres) Delete(table string, values map[string]string) error

Delete removes rows matching values from table.

func (*Postgres) Exists

func (p *Postgres) Exists(table string, values map[string]string) (bool, error)

Exists takes a table to check and a map representing a row to compare to and returns true if there is a match in the database.

func (*Postgres) Get

func (p *Postgres) Get(table string, values map[string]string, columns ...string) ([]map[string]string, error)

Get gets teh columns from the table for the rows matching values.

func (*Postgres) Set

func (p *Postgres) Set(table string, values, cond map[string]string) error

Set finds a row matching cond in table and sets the column/value pairs in values.

Jump to

Keyboard shortcuts

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