Skip to content

hero.db.core #

fn new_dbhandler #

fn new_dbhandler[T](prefix string, session_state SessionState) DBHandler[T]

new_dbhandler creates a new DBHandler for type T

fn new_session #

fn new_session(args_ StateArgs) !SessionState

fn (DBHandler[T]) set #

fn (mut m DBHandler[T]) set(item_ T) !T

set adds or updates an item

fn (DBHandler[T]) get_data #

fn (mut m DBHandler[T]) get_data(id u32) ![]u8

get retrieves an item by its ID

fn (DBHandler[T]) exists #

fn (mut m DBHandler[T]) exists(id u32) !bool

fn (DBHandler[T]) get_data_by_key #

fn (mut m DBHandler[T]) get_data_by_key(key_field string, key_value string) ![]u8

get_by_key retrieves an item by a specific key field and value

fn (DBHandler[T]) delete #

fn (mut m DBHandler[T]) delete(item T) !

delete removes an item by its ID

fn (DBHandler[T]) list #

fn (mut m DBHandler[T]) list() ![]u32

list returns all ids from the db handler

fn (DBHandler[T]) list_by_prefix #

fn (mut m DBHandler[T]) list_by_prefix(key_field string, prefix_value string) ![]u32

list_by_prefix returns all items that match a specific prefix pattern

struct DBHandler #

struct DBHandler[T] {
pub mut:
	prefix        string
	session_state SessionState
}

import freeflowuniverse.herolib.hero.db.managers.circle as circle_models

struct Databases #

struct Databases {
pub mut:
	db_data_core &ourdb.OurDB
	db_meta_core &radixtree.RadixTree
	db_data_mcc  &ourdb.OurDB
	db_meta_mcc  &radixtree.RadixTree
}

struct SessionState #

struct SessionState {
pub mut:
	name   string
	pubkey string // pubkey of user who called this
	addr   string // mycelium address
	dbs    Databases
}

SessionState holds the state of a session which is linked to someone calling it as well as the DB's we use

struct StateArgs #

@[params]
struct StateArgs {
pub mut:
	name   string
	pubkey string // pubkey of user who called this
	addr   string // mycelium address
	path   string
}