Back to godoc.org

Package sqlds

v1.0.1
Latest Go to latest
Published: Jul 31, 2020 | License: AGPL-3.0 | Module: github.com/RTradeLtd/go-datastores

Index

Package Files

Variables

var (

	// ErrNotImplemented is returned when the SQL datastore does not yet implement the function call.
	ErrNotImplemented = fmt.Errorf("not implemented")
)

type Datastore

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

Datastore is a SQL backed datastore.

func NewDatastore

func NewDatastore(db *sql.DB, queries Queries) *Datastore

NewDatastore returns a new SQL datastore.

func (*Datastore) Batch

func (d *Datastore) Batch() (ds.Batch, error)

Batch creates a set of deferred updates to the database. Since SQL does not support a true batch of updates, operations are buffered and then executed sequentially over a single connection when Commit is called.

func (*Datastore) Close

func (d *Datastore) Close() error

Close closes the underying SQL database.

func (*Datastore) Delete

func (d *Datastore) Delete(key ds.Key) error

Delete removes a row from the SQL database by the given key.

func (*Datastore) Get

func (d *Datastore) Get(key ds.Key) (value []byte, err error)

Get retrieves a value from the SQL database by the given key.

func (*Datastore) GetSize

func (d *Datastore) GetSize(key ds.Key) (int, error)

GetSize determines the size in bytes of the value for a given key.

func (*Datastore) Has

func (d *Datastore) Has(key ds.Key) (exists bool, err error)

Has determines if a value for the given key exists in the SQL database.

func (*Datastore) NewTransaction

func (ds *Datastore) NewTransaction(_ bool) (ds.Txn, error)

NewTransaction creates a new database transaction, note the readOnly parameter is ignored by this implementation.

func (*Datastore) Put

func (d *Datastore) Put(key ds.Key, value []byte) error

Put "upserts" a row into the SQL database.

func (*Datastore) Query

func (d *Datastore) Query(q dsq.Query) (dsq.Results, error)

Query returns multiple rows from the SQL database based on the passed query parameters.

func (*Datastore) Sync

func (d *Datastore) Sync(key ds.Key) error

Sync is noop for SQL databases.

type Queries

type Queries interface {
	Delete() string
	Exists() string
	Get() string
	Put() string
	Query() string
	Prefix() string
	Limit() string
	Offset() string
	GetSize() string
}

Queries generates SQL queries for datastore operations.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier