storage

package module
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

gidari-pg

Build Status Go Report Card

Gidari PG is the PostgreSQL implmentation of the Gidari Storage interface. To install run

go get github.com/alpstable/gidari-pg@0.0.1-alpha

Documentation

Overview

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Copyright 2022 The Gidari PG Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0\n

Index

Constants

View Source
const Version = "0.0.0-alpha"

Variables

View Source
var (
	ErrTransactionNotFound   = fmt.Errorf("transaction not found")
	ErrNoTables              = fmt.Errorf("no tables found")
	ErrUnsupportedDataType   = fmt.Errorf("unsupported data type")
	ErrFailedToMarshalJSON   = fmt.Errorf("failed to marshal json")
	ErrFailedToUnmarshalJSON = fmt.Errorf("failed to unmarshal json")
)

Functions

func New

func New(ctx context.Context, connectionURL string) (proto.Storage, error)

New will return a new Postgres option for querying data through a Postgres DB.

Types

type Postgres

type Postgres struct {
	*sql.DB
	// contains filtered or unexported fields
}

Postgres is a wrapper around the sql.DB object.

func (*Postgres) Close

func (pg *Postgres) Close()

Close will close the underlying database / transaction.

func (*Postgres) IsNoSQL

func (pg *Postgres) IsNoSQL() bool

IsNoSQL returns "false" to indicate that "Postgres" is not a NoSQL database.

func (*Postgres) ListColumns

func (pg *Postgres) ListColumns(ctx context.Context) (*proto.ListColumnsResponse, error)

ListColumns will set a complete list of available columns per table on the response.

func (*Postgres) ListPrimaryKeys

func (pg *Postgres) ListPrimaryKeys(ctx context.Context) (*proto.ListPrimaryKeysResponse, error)

ListPrimaryKeys will list all primary keys for all of the tables in the database defined by the DNS used to create the postgres instance.

func (*Postgres) ListTables

func (pg *Postgres) ListTables(ctx context.Context) (*proto.ListTablesResponse, error)

ListTables will set a complete list of available tables on the response.

func (*Postgres) StartTx

func (pg *Postgres) StartTx(ctx context.Context) (*proto.Txn, error)

StartTx will start a transaction on the Postgres connection. The transaction ID is returned and should be used to commit or rollback the transaction.

func (*Postgres) Truncate

Truncate will truncate a table.

func (*Postgres) Type

func (pg *Postgres) Type() uint8

Type implements the storage interface.

func (*Postgres) Upsert

Upsert will insert the records on the request if they do not exist in the database. On conflict, it will use the PK on the request record to update the data in the database. An upsert request will update the entire table for a given record, include fields that have not been set directly.

Jump to

Keyboard shortcuts

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