jdb

package
v0.0.0-...-522b25d Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init initializes the JSON-DB.

Types

type JDB

type JDB interface {
	List() ([]jsondb.JID, error)
	Put(jo jsondb.JSONObj) (jsondb.JSONObj, error)
	Get(id jsondb.JID) (jo jsondb.JSONObj, ok bool, err error)
	Del(id jsondb.JID) (ok bool, err error)

	Dump() ([]jsondb.JSONObj, error)
	Load(data []map[string]any) error
	Ping() error
}

JDB is the principal interface to direct access of a JSON-DB

func InitMemoryJDB

func InitMemoryJDB(data []map[string]any) JDB

func InitSqliteJDB

func InitSqliteJDB(dsn string) (JDB, error)

func NewMemoryJDB

func NewMemoryJDB() JDB

func NewSqlJDB

func NewSqlJDB(db *sql.DB) JDB

type SqlJDB

type SqlJDB struct {
	DB *sql.DB
}

func (*SqlJDB) Del

func (jdb *SqlJDB) Del(id jsondb.JID) (ok bool, err error)

func (*SqlJDB) Dump

func (jdb *SqlJDB) Dump() ([]jsondb.JSONObj, error)

func (*SqlJDB) Get

func (jdb *SqlJDB) Get(id jsondb.JID) (jo jsondb.JSONObj, ok bool, err error)

func (*SqlJDB) List

func (jdb *SqlJDB) List() ([]jsondb.JID, error)

func (*SqlJDB) Load

func (jdb *SqlJDB) Load(data []map[string]any) error

func (*SqlJDB) Ping

func (jdb *SqlJDB) Ping() error

func (*SqlJDB) Put

func (jdb *SqlJDB) Put(jo jsondb.JSONObj) (jsondb.JSONObj, error)

Jump to

Keyboard shortcuts

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