indexeddb

package module
v0.0.0-...-96df21b Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
var (
	IndexedDB = js.Global().Get("indexedDB")
	Object    = js.Global().Get("Object")
	Array     = js.Global().Get("Array")
)
View Source
var (
	ErrValueNotFound = errors.New("value not found")
	ErrKeyInvalid    = errors.New("key is invalid")
	ErrValueInvalid  = errors.New("value is invalid")
	ErrInvalidType   = errors.New("type is not accepted")
)
View Source
var Logger *slog.Logger

Functions

This section is empty.

Types

type Batch

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

func (*Batch) Add

func (b *Batch) Add(key, value any) error

func (*Batch) Put

func (b *Batch) Put(key, value any) error

func (*Batch) Wait

func (b *Batch) Wait() error

type DB

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

https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase.

func New

func New(name string, version int, upgrade func(up *Upgrade) error) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

close the database.

func (*DB) NewTransaction

func (db *DB) NewTransaction(stores []string, mode Mode) (*Transaction, error)

type Index

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

func (*Index) Get

func (i *Index) Get(key any) (*js.Value, error)

type Mode

type Mode int
const (
	ReadMode Mode = iota
	ReadWriteMode
)

func (Mode) String

func (m Mode) String() string

func (Mode) Verify

func (m Mode) Verify() bool

type Store

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

func (*Store) Add

func (s *Store) Add(key, value any) error

func (*Store) Batch

func (s *Store) Batch() *Batch

func (*Store) Clear

func (s *Store) Clear() error

func (*Store) Count

func (s *Store) Count() (int, error)

func (*Store) Delete

func (s *Store) Delete(key any) error

func (*Store) Get

func (s *Store) Get(key any) (*js.Value, error)

get is a query for the key.

func (*Store) GetAll

func (s *Store) GetAll() ([]js.Value, error)

func (*Store) Index

func (s *Store) Index(name string) *Index

func (*Store) NewIndex

func (s *Store) NewIndex(name string) *Index

func (*Store) Put

func (s *Store) Put(key any, value any) error

put is either an insert or an update,

type StoreConfig

type StoreConfig struct {
	KeyPath       string
	AutoIncrement bool
}

type Transaction

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

https://developer.mozilla.org/en-US/docs/Web/API/IDBTransaction.

func (*Transaction) Store

func (tx *Transaction) Store(name string) *Store

type Upgrade

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

an upgrade is a database connection before needing it's objects/indexes established.

func (*Upgrade) CreateStore

func (up *Upgrade) CreateStore(name string)

deprecated use `NewStore` instead.

func (*Upgrade) NewStore

func (up *Upgrade) NewStore(name string, cfg *StoreConfig) *Store

Jump to

Keyboard shortcuts

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