indexdb

package module
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 4 Imported by: 0

README

indexdb

implementación de index dB con Websassembly compilado con go (golang)

Contributing

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(cb func() (js.Value, error)) js.Value

func CreateBlobURL

func CreateBlobURL(blob any) string

CreateBlobURL crea una URL Blob a partir de un blob.

func PromiseError

func PromiseError(e interface{}) (err js.Value)

PromiseError makes sure to return some error that Invoke will understand.

func PromiseOf

func PromiseOf(fn PromiseAbleFunc) js.Func

MakePromise hace una promesa de una función que toma una serie de argumentos.

Types

type IndexDB

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

func New

func New(dbName string, idg idGenerator, logger func(...any)) *IndexDB

New creates a new IndexDB instance with the given database name, ID generator, and logger.

type idGenerator interface {
	GetNewID() string
}

func (*IndexDB) ClearAllTableDataInDB

func (d *IndexDB) ClearAllTableDataInDB(tables ...string) (err error)

func (*IndexDB) Create

func (d *IndexDB) Create(table_name string, items ...any) (err error)

items support: []any (struct instances)

func (*IndexDB) CreateTableIfNotExists

func (d *IndexDB) CreateTableIfNotExists(tableName string, structType any) error

CreateTableIfNotExists creates a table for the given struct type if it doesn't exist

func (*IndexDB) Delete

func (d *IndexDB) Delete(table_name string, items ...any) (err error)

func (*IndexDB) InitDB

func (d *IndexDB) InitDB(structTables ...any)

InitDB require structs with interface structName { StructName() string } for table names eg: type User struct { NameField string } => User.StructName() string { return "user" } eg: type Product struct { NameField string } => Product.StructName() string { return "product" } then call: indexdb.InitDB(User{}, Product{}) This is because Reflect support is not complete, it is the only way this library can be compatible with TinyGo.

func (*IndexDB) Read

func (d *IndexDB) Read(p *ReadParams, callback func(r *ReadResults, err error))

func (*IndexDB) ReadStringDataInDB

func (d *IndexDB) ReadStringDataInDB(r *ReadParams) (out []interface{}, err error)

func (*IndexDB) ReadStringDataInDBold

func (d *IndexDB) ReadStringDataInDBold(r *ReadParams) (out []map[string]string, err error)

func (IndexDB) TableExist

func (d IndexDB) TableExist(table_name string) bool

TableExist checks if a table exists in the database

func (*IndexDB) Update

func (d *IndexDB) Update(table_name string, items ...any) (err error)

type PromiseAbleFunc

type PromiseAbleFunc = func(js.Value, []js.Value) (interface{}, error)

https://go-review.googlesource.com/c/go/+/402455/3/src/syscall/js/promise.go Función prometedora que satisface los requisitos de MakePromise.

type ReadParams

type ReadParams struct {
	FROM_TABLE string
	SORT_DESC  bool
	ID         string
	ORDER_BY   string
	WHERE      []interface{}
	RETURN_ANY bool
}

type ReadResults

type ReadResults struct {
	Results []interface{}
	Error   error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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