impl

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const (

	// ErrDoesNotExist is an error string for got undefined on Get operations.
	ErrDoesNotExist = "result is undefined"
)

Variables

This section is empty.

Functions

func Delete

func Delete(db *idb.Database, objectStoreName string, key js.Value) error

Delete is a generic helper for removing values from the given idb.ObjectStore. Only usable by primary key.

func DeleteIndex

func DeleteIndex(db *idb.Database, objectStoreName,
	indexName, pkeyName string, key js.Value) error

DeleteIndex is a generic helper for removing values from the given idb.ObjectStore using the given idb.Index. Requires passing in the name of the primary key for the store.

func Dump

func Dump(db *idb.Database, objectStoreName string) ([]string, error)

Dump returns the given idb.ObjectStore contents to string slice for testing and debugging purposes.

func EncodeBytes

func EncodeBytes(input []byte) js.Value

EncodeBytes returns the proper IndexedDb encoding for a byte slice into js.Value.

func Get

func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, error)

Get is a generic helper for getting values from the given idb.ObjectStore. Only usable by primary key.

func GetAll

func GetAll(db *idb.Database, objectStoreName string) ([]js.Value, error)

GetAll is a generic helper for getting all values from the given idb.ObjectStore.

func GetIndex

func GetIndex(db *idb.Database, objectStoreName,
	indexName string, key js.Value) (js.Value, error)

GetIndex is a generic helper for getting values from the given idb.ObjectStore using the given idb.Index.

func NewContext

func NewContext() (context.Context, context.CancelFunc)

NewContext builds a context for indexedDb operations.

func Put

func Put(db *idb.Database, objectStoreName string, value js.Value) (js.Value, error)

Put is a generic helper for putting values into the given idb.ObjectStore. Equivalent to insert if not exists else update. Returns the primary key of the stored object as a js.Value.

func SendCursorRequest added in v0.3.4

func SendCursorRequest(cur *idb.CursorWithValueRequest,
	iterFunc func(cursor *idb.CursorWithValue) error) error

SendCursorRequest is a wrapper for the cursorRequest.Await() method providing a timeout.

func SendRequest added in v0.3.4

func SendRequest(request *idb.Request) (js.Value, error)

SendRequest is a wrapper for the request.Await() method providing a timeout.

Types

type WebState added in v0.3.4

type WebState interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
}

WebState defines an interface for setting persistent state in a KV format specifically for web-based implementations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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