sqlds

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 5 Imported by: 6

README

SQL Datastore

An implementation of the datastore interface that can be backed by any sql database.

Usage

import (
	"database/sql"
	"github.com/ipfs/go-ds-sql"
)

mydb, _ := sql.Open("yourdb", "yourdbparameters")

ds := sqlds.NewSqlDatastore(mydb)

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryWithParams

func QueryWithParams(d *Datastore, q dsq.Query) (*sql.Rows, error)

QueryWithParams applies prefix, limit, and offset params in pg query

Types

type Datastore

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

func NewDatastore

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

NewDatastore returns a new datastore

func (*Datastore) Batch

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

func (*Datastore) Close

func (d *Datastore) Close() error

func (*Datastore) Delete

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

func (*Datastore) Get

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

func (*Datastore) GetSize

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

func (*Datastore) Has

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

func (*Datastore) Put

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

func (*Datastore) Query

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

func (*Datastore) RawQuery

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

func (*Datastore) Sync

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

type Queries

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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