postgresqldatabase

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 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 Database

type Database struct {
	upperdb.Session
	Host string
}

Database defines a connection to a PostgreSQL database.

func New

func New(ctx context.Context, uri string) (*Database, error)

New creates and opens a connection to a PostgreSQL database. It closes the connection when the provided context is terminated.

func NewWithSession

func NewWithSession(db *Database, session upperdb.Session) *Database

NewWithSession is used during tests to instantiate a new database with the specified session.

func (*Database) Count

func (db *Database) Count(rt resource.Type, filters []*query.Filter) (int, error)

Count retrieves the number of resources of the specified resource type, based on the filters.

func (*Database) Create

func (db *Database) Create(rt resource.Type, res resource.Resource) (uuid.UUID, error)

Create creates a new resource based on the provided res. The function returns its new id.

func (*Database) Delete

func (db *Database) Delete(rt resource.Type, id uuid.UUID) error

Delete deletes the resource matching the provided res by its ID field.

func (*Database) RetrieveByID

func (db *Database) RetrieveByID(rt resource.Type, id uuid.UUID, res interface{}) error

Retrieve retrieves the resource matching the specified id.

func (*Database) RetrieveByIDOrCode

func (db *Database) RetrieveByIDOrCode(rt resource.Type, idOrCode string, res interface{}) error

func (*Database) RetrieveMany

func (db *Database) RetrieveMany(rt resource.Type, q *query.Query, resources interface{}) error

RetrieveMany retrieves a collection of resources, based on the specified database.

func (*Database) RetrieveNamespaceChildrenIDs

func (db *Database) RetrieveNamespaceChildrenIDs(namespaceIDs []uuid.UUID) ([]uuid.UUID, error)

func (*Database) RetrieveNamespaceParentIDs

func (db *Database) RetrieveNamespaceParentIDs(namespaceID uuid.UUID) ([]uuid.UUID, error)

func (*Database) Update

func (db *Database) Update(rt resource.Type, id uuid.UUID, res resource.Resource) error

Update updates an existing resource matching the provided res by its ID field and updates all of its attributes.

Jump to

Keyboard shortcuts

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