PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/datastore

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
datastore
Namespace
g17khqpukees4237dtn3astzapmp462vjhsz6st4
Files
11 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/datastore
gno
0.9

Files (11)

  • README.mdmarkdown
  • gnomod.tomltoml
  • datastore.gnogno
  • index.gnogno
  • query_options.gnogno
  • query.gnogno
  • record.gnogno
  • schema_options.gnogno
  • schema.gnogno
  • storage_options.gnogno
  • storage.gnogno
  • datastore.gnogno
    1// Package datastore provides support to store multiple collections of records.2package datastore34import (5	"errors"67	"gno.land/p/nt/bptree/v0"8)910// ErrStorageExists indicates that a storage exists with the same name.11var ErrStorageExists = errors.New("a storage with the same name exists")1213// NewDatastore creates a new store.14func NewDatastore() *Datastore {15	return &Datastore{16		storages: bptree.NewBPTree32(),17	}18}1920// Datastore is a store that can contain multiple named storages.21// A storage is a collection of records.22//23// Example usage:24//25//	// Create an empty storage to store user records26//	var db Datastore27//	storage := db.CreateStorage("users")28//29//	// Get a storage that has been created before30//	storage = db.GetStorage("profiles")31type Datastore struct {32	storages *bptree.BPTree // string(name) -> *Storage33}3435// CreateStorage creates a new named storage within the data store.36func (ds *Datastore) CreateStorage(name string, options ...StorageOption) *Storage {37	if ds.storages.Has(name) {38		return nil39	}4041	s := NewStorage(name, options...)42	ds.storages.Set(name, &s)43	return &s44}4546// HasStorage checks if data store contains a storage with a specific name.47func (ds *Datastore) HasStorage(name string) bool {48	return ds.storages.Has(name)49}5051// GetStorage returns a storage that has been created with a specific name.52// It returns nil when a storage with the specified name is not found.53func (ds *Datastore) GetStorage(name string) *Storage {54	if s, ok := ds.storages.Get(name).(*Storage); ok {55		return s56	}57	return nil58}59

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.