indexed_db

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const (
	// The cursor shows all records, including duplicates.
	// It starts at the lower bound of the key range and moves
	// upwards (monotonically increasing in the order of keys).
	CursorDirectionNext = "next"
	// The cursor shows all records, excluding duplicates.
	// If multiple records exist with the same key, only the
	// first one iterated is retrieved. It starts at the lower
	// bound of the key range and moves upwards.
	CursorDirectionNextUnique = "nextunique"
	// The cursor shows all records, including duplicates.
	// It starts at the upper bound of the key range and moves
	// downwards (monotonically decreasing in the order of keys).
	CursorDirectionPrev = "prev"
	// The cursor shows all records, excluding duplicates.
	// If multiple records exist with the same key, only the
	// first one iterated is retrieved. It starts at the upper
	// bound of the key range and moves downwards.
	CursorDirectionPrevUnique = "prevunique"
)
View Source
const (
	// The blocked handler is executed when an open
	// connection to a database is blocking a
	// versionchange transaction on the same database.
	BlockedEvent = "blocked"
	// The upgradeneeded event is fired when an attempt
	// was made to open a database with a version number
	// higher than its current version.
	UpgradeNeededEvent = "upgradeneeded"
)
View Source
const (
	// The error handler is executed when an error
	// caused a request to fail.
	ErrorEvent = "error"
	// The success event is fired when an IDBRequest succeeds.
	SuccessEvent = "success"
)
View Source
const (
	TransactionModeReadOnly       = "readonly"
	TransactionModeReadWrite      = "readwrite"
	TransactionModeReadWriteFlush = "readwriteflush"
	TransactionDurabilityDefault  = "default"
	TransactionDurabilityStrict   = "strict"
	TransactionDurabilityRelaxed  = "relaxed"
	// The abort event is fired when an IndexedDB transaction is aborted.
	AbortEvent = "abort"
	// The complete event of the IndexedDB API is fired when the transaction successfully completed.
	CompleteEvent = "complete"
)

Variables

View Source
var IndexOptions = &indexOptions{}

IndexOptions is used to set index options.

View Source
var KeyRange keyRange

KeyRange wraps the IDBKeyRange global interface.

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

View Source
var ObjectStoreOptions = &objectStoreOptions{}

ObjectStoreOptions is used to set object store options.

View Source
var TransactionOptions = &transactionOptions{}

TransactionOptions is used to set transaction options.

Functions

func Await

func Await[T RequestResult](request RequestValue[T]) (res T, err error)

Await is a helper that waits for a request and returns the result and error.

func Cmp

func Cmp(first any, second any) int

Cmp wraps the IDBFactory cmp method.

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

func Databases

func Databases() goji.PromiseValue

Databases wraps the IDBFactory databases method.

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

func WithMultiEntry added in v0.0.3

func WithMultiEntry(enabled bool) indexOption

WithMultiEntry sets the index multiEntry option.

https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/createIndex#multientry

func WithUnique added in v0.0.3

func WithUnique(enabled bool) indexOption

WithUnique sets the index unique option.

https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/createIndex#unique

Types

type CursorValue

type CursorValue js.Value

CursorValue is an instance of IDBCursor.

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

func (CursorValue) Advance

func (c CursorValue) Advance(count uint)

Advance wraps the IDBCursor advance instance method.

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

func (CursorValue) Continue

func (c CursorValue) Continue(args ...any)

Continue wraps the IDBCursor continue instance method.

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

func (CursorValue) ContinuePrimaryKey

func (c CursorValue) ContinuePrimaryKey(key any, primaryKey any)

ContinuePrimaryKey wraps the IDBCursor continuePrimaryKey instance method.

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

func (CursorValue) Delete

func (c CursorValue) Delete() RequestValue[js.Value]

Delete wraps the IDBCursor delete instance method.

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

func (CursorValue) Direction

func (c CursorValue) Direction() string

Direction returns the IDBCursor direction property.

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

func (CursorValue) Key

func (c CursorValue) Key() js.Value

Key returns the IDBCursor key property.

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

func (CursorValue) PrimaryKey

func (c CursorValue) PrimaryKey() js.Value

PrimaryKey returns the IDBCursor primaryKey property.

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

func (CursorValue) Request

func (c CursorValue) Request() RequestValue[js.Value]

Request returns the IDBCursor request property.

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

func (CursorValue) Source

func (c CursorValue) Source() js.Value

Source returns the IDBCursor request property.

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

func (CursorValue) Update

func (c CursorValue) Update(value any) RequestValue[js.Value]

Update wraps the IDBCursor update instance method.

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

func (CursorValue) Value added in v0.0.4

func (c CursorValue) Value() js.Value

Value returns the IDBCursorWithValue value property.

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

type DatabaseValue

type DatabaseValue js.Value

DatabaseValue is an instance of IDBDatabase

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

func (DatabaseValue) Close

func (d DatabaseValue) Close()

Close wraps the IDBDatabase close instance method.

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

func (DatabaseValue) CreateObjectStore

func (d DatabaseValue) CreateObjectStore(name string, opts ...objectStoreOption) ObjectStoreValue

CreateObjectStore wraps the IDBDatabase createObjectStore instance method.

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

func (DatabaseValue) DeleteObjectStore

func (d DatabaseValue) DeleteObjectStore(name string)

DeleteObjectStore wraps the IDBDatabase deleteObjectStore instance method.

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

func (DatabaseValue) Name

func (d DatabaseValue) Name() string

Name returns the IDBDatabase name property.

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

func (DatabaseValue) ObjectStoreNames

func (d DatabaseValue) ObjectStoreNames() js.Value

ObjectStoreNames returns the IDBDatabase objectStoreNames property.

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

func (DatabaseValue) Transaction

func (d DatabaseValue) Transaction(storeNames any, mode string, opts ...transactionOption) TransactionValue

Transaction wraps the IDBDatabase transaction instance method.

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

func (DatabaseValue) Version

func (d DatabaseValue) Version() int

Version returns the IDBDatabase version property.

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

type IndexValue

type IndexValue js.Value

IndexValue is an IDBIndex instance.

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

func (IndexValue) Count

func (i IndexValue) Count(key any) RequestValue[js.Value]

Count wraps the IDBIndex count instance method.

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

func (IndexValue) Get

func (i IndexValue) Get(key any) RequestValue[js.Value]

Get wraps the IDBIndex get instance method.

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

func (IndexValue) GetAll

func (i IndexValue) GetAll(args ...any) RequestValue[js.Value]

GetAll wraps the IDBIndex getAll instance method.

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

func (IndexValue) GetAllKeys

func (i IndexValue) GetAllKeys(args ...any) RequestValue[js.Value]

GetAllKeys wraps the IDBIndex getAllKeys instance method.

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

func (IndexValue) GetKey

func (i IndexValue) GetKey(key any) RequestValue[js.Value]

GetKey wraps the IDBIndex getKey instance method.

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

func (IndexValue) KeyPath

func (i IndexValue) KeyPath() js.Value

KeyPath returns the IDBIndex keyPath property.

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

func (IndexValue) MultiEntry

func (i IndexValue) MultiEntry() bool

MultiEntry returns the IDBIndex multiEntry property.

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

func (IndexValue) Name

func (i IndexValue) Name() string

Name returns the IDBIndex name property.

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

func (IndexValue) ObjectStore

func (i IndexValue) ObjectStore() ObjectStoreValue

ObjectStore returns the IDBIndex objectStore property.

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

func (IndexValue) OpenCursor

func (i IndexValue) OpenCursor(args ...any) RequestValue[CursorValue]

OpenCursor wraps the IDBIndex openCursor instance method.

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

func (IndexValue) OpenKeyCursor

func (i IndexValue) OpenKeyCursor(args ...any) RequestValue[CursorValue]

OpenKeyCursor wraps the IDBIndex openKeyCursor instance method.

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

func (IndexValue) Unique

func (i IndexValue) Unique() bool

Unique returns the IDBIndex unique property.

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

type KeyRangeValue

type KeyRangeValue js.Value

KeyRangeValue is an instance of IDBKeyRange.

func (KeyRangeValue) Includes

func (k KeyRangeValue) Includes(key any) bool

Includes wraps the IDBKeyRange includes instance method.

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

func (KeyRangeValue) Lower

func (k KeyRangeValue) Lower() js.Value

Lower returns the IDBKeyRange lower property.

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

func (KeyRangeValue) LowerOpen

func (k KeyRangeValue) LowerOpen() bool

LowerOpen returns the IDBKeyrange lowerOpen property.

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

func (KeyRangeValue) Upper

func (k KeyRangeValue) Upper() js.Value

Upper returns the IDBKeyRange upper property.

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

func (KeyRangeValue) UpperOpen

func (k KeyRangeValue) UpperOpen() bool

UpperOpen returns the IDBKeyRange upperOpen property.

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

type ObjectStoreValue

type ObjectStoreValue js.Value

ObjectStoreValue is an instance of IDBObjectStore.

func (ObjectStoreValue) Add

func (o ObjectStoreValue) Add(args ...any) RequestValue[js.Value]

Add wraps the IDBObjectStore add instance method.

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

func (ObjectStoreValue) AutoIncrement

func (o ObjectStoreValue) AutoIncrement() bool

AutoIncrement returns the IDBObjectStore autoIncrement property.

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

func (ObjectStoreValue) Clear

Clear wraps the IDBObjectStore clear instance method.

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

func (ObjectStoreValue) Count

func (o ObjectStoreValue) Count(query any) RequestValue[js.Value]

Count wraps the IDBObjectStore count instance method.

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

func (ObjectStoreValue) CreateIndex

func (o ObjectStoreValue) CreateIndex(indexName string, keyPath any, opts ...indexOption) IndexValue

CreateIndex wraps the IDBObjectStore createIndex instance method.

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

func (ObjectStoreValue) Delete

func (o ObjectStoreValue) Delete(key any) RequestValue[js.Value]

Delete wraps the IDBObjectStore delete instance method.

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

func (ObjectStoreValue) DeleteIndex

func (o ObjectStoreValue) DeleteIndex(key any)

DeleteIndex wraps the IDBObjectStore deleteIndex instance method.

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

func (ObjectStoreValue) Get

Get wraps the IDBObjectStore get instance method.

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

func (ObjectStoreValue) GetAll

func (o ObjectStoreValue) GetAll(args ...any) RequestValue[js.Value]

GetAll wraps the IDBObjectStore getAll instance method.

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

func (ObjectStoreValue) GetAllKeys

func (o ObjectStoreValue) GetAllKeys(args ...any) RequestValue[js.Value]

GetAllKeys wraps the IDBObjectStore getAllKeys instance method.

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

func (ObjectStoreValue) GetKey

func (o ObjectStoreValue) GetKey(key any) RequestValue[js.Value]

GetKey wraps the IDBObjectStore getKey instance method.

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

func (ObjectStoreValue) Index

func (o ObjectStoreValue) Index(name string) IndexValue

Index wraps the IDBObjectStore index instance method.

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

func (ObjectStoreValue) IndexNames

func (o ObjectStoreValue) IndexNames() js.Value

IndexNames returns the IDBObjectStore indexNames property.

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

func (ObjectStoreValue) KeyPath

func (o ObjectStoreValue) KeyPath() js.Value

KeyPath returns the IDBObjectStore keyPath property.

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

func (ObjectStoreValue) Name

func (o ObjectStoreValue) Name() string

Name returns the IDBObjectStore name property.

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

func (ObjectStoreValue) OpenCursor

func (o ObjectStoreValue) OpenCursor(args ...any) RequestValue[CursorValue]

OpenCursor wraps the IDBObjectStore openCursor instance method.

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

func (ObjectStoreValue) OpenKeyCursor

func (o ObjectStoreValue) OpenKeyCursor(args ...any) RequestValue[CursorValue]

OpenKeyCursor wraps the IDBObjectStore openKeyCursor instance method.

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

func (ObjectStoreValue) Put

func (o ObjectStoreValue) Put(args ...any) RequestValue[js.Value]

Put wraps the IDBObjectStore put instance method.

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

func (ObjectStoreValue) Transaction

func (o ObjectStoreValue) Transaction() TransactionValue

Transaction returns the IDBObjectStore transaction property.

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

type RequestResult added in v0.0.3

type RequestResult interface {
	js.Value | DatabaseValue | CursorValue
}

RequestResult is the type union for request results.

type RequestValue

type RequestValue[T RequestResult] js.Value

RequestValue is an instance of IDBRequest.

func DeleteDatabase

func DeleteDatabase(name string) RequestValue[js.Value]

DeleteDatabase wraps the IDBFactory deleteDatabase method.

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

func Open

func Open(name string, version uint) RequestValue[DatabaseValue]

Open wraps the IDBFactory open method.

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

func (RequestValue[T]) Error

func (r RequestValue[T]) Error() js.Value

Error returns the IDBRequest error property.

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

func (RequestValue[T]) EventTarget added in v0.0.3

func (r RequestValue[T]) EventTarget() goji.EventTargetValue

EventTarget returns the EventTarget for the request.

func (RequestValue[T]) ReadyState

func (r RequestValue[T]) ReadyState() string

ReadyState returns the IDBRequest readyState property.

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

func (RequestValue[T]) Result

func (r RequestValue[T]) Result() T

Result returns the IDBRequest result property.

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

func (RequestValue[T]) Source

func (r RequestValue[T]) Source() js.Value

Source returns the IDBRequest source property.

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

func (RequestValue[T]) Transaction

func (r RequestValue[T]) Transaction() TransactionValue

Transaction returns the IDBRequest transaction property.

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

type TransactionValue

type TransactionValue js.Value

TransactionValue is an instance of IDBTransaction.

func (TransactionValue) Abort

func (t TransactionValue) Abort()

Abort wraps the IDBTransaction abort instance method.

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

func (TransactionValue) Commit

func (t TransactionValue) Commit()

Commit wraps the IDBTransaction commit instance method.

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

func (TransactionValue) DB

DB returns the IDBTransaction db property.

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

func (TransactionValue) Durability

func (t TransactionValue) Durability() string

Durability returns the IDBTransaction durability property.

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

func (TransactionValue) Error

func (t TransactionValue) Error() js.Value

Error returns the IDBTransaction error property.

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

func (TransactionValue) Mode

func (t TransactionValue) Mode() string

String returns the IDBTransaction mode property.

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

func (TransactionValue) ObjectStore

func (t TransactionValue) ObjectStore(name string) ObjectStoreValue

ObjectStore wraps the IDBTransaction objectStore instance method.

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

func (TransactionValue) ObjectStoreNames

func (t TransactionValue) ObjectStoreNames() js.Value

ObjectStoreNames returns the IDBTransaction objectStoreNames property.

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

Jump to

Keyboard shortcuts

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