embed

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(dbname, collname string, spec map[string]any) int

Count records in BadgerDB

func Distinct

func Distinct(dbname, collname, field string) ([]any, error)

Distinct gets number records from document-oriented db

func Get

func Get(dbname, collname string, spec map[string]any, idx, limit int) []map[string]any

Get records from BadgerDB

func GetSorted

func GetSorted(dbname, collname string, spec map[string]any, skeys []string, sortOrder, idx, limit int) []map[string]any

GetSorted fetches records from document-oriented db sorted by given key with specific order

func InitDB

func InitDB(dbDir string) error

InitDB initializes the Badger database

func Insert added in v0.5.3

func Insert(dbname, collname string, records []map[string]any)

Insert records into BadgerDB

func InsertRecord

func InsertRecord(dbname, collname string, rec map[string]any) error

InsertRecord insert record with given spec to document-oriented db

func Remove

func Remove(dbname, collname string, spec map[string]any) error

Remove records from BadgerDB

func Update

func Update(dbname, collname string, spec, newdata map[string]any)

Update records in BadgerDB

func Upsert

func Upsert(dbname, collname, attr string, records []map[string]any) error

Upsert records into BadgerDB

Types

type EmbedDB added in v0.5.9

type EmbedDB struct {
}

EmbedDB represent embedded database

func (*EmbedDB) Count added in v0.5.9

func (d *EmbedDB) Count(dbname, collname string, spec map[string]any) int

Count returns total number of records within database/collection and given spec

func (*EmbedDB) Distinct added in v0.5.9

func (d *EmbedDB) Distinct(dbname, collname, field string) ([]any, error)

Distinct returns distinct collection of records

func (*EmbedDB) Get added in v0.5.9

func (d *EmbedDB) Get(dbname, collname string, spec map[string]any, idx, limit int) []map[string]any

Get fetches data from underlying database/collection

func (*EmbedDB) GetSorted added in v0.5.9

func (d *EmbedDB) GetSorted(dbname, collname string, spec map[string]any, skeys []string, sortOrder, idx, limit int) []map[string]any

GetSorted returns sorted records from given database/collection using provided spec, sorted keys, order and limits

func (*EmbedDB) InitDB added in v0.5.9

func (d *EmbedDB) InitDB(uri string)

InitDB initialize embedded database

func (*EmbedDB) Insert added in v0.5.9

func (d *EmbedDB) Insert(dbname, collname string, records []map[string]any)

Insert inserts records into provided database/collection

func (*EmbedDB) InsertRecord added in v0.5.9

func (d *EmbedDB) InsertRecord(dbname, collname string, rec map[string]any) error

InsertRecord inserts single record into given database/collection

func (*EmbedDB) Remove added in v0.5.9

func (d *EmbedDB) Remove(dbname, collname string, spec map[string]any) error

Remove deletes records in given database/collection using given spec

func (*EmbedDB) Update added in v0.5.9

func (d *EmbedDB) Update(dbname, collname string, spec, newdata map[string]any)

Update updates data into given database/collection

func (*EmbedDB) Upsert added in v0.5.9

func (d *EmbedDB) Upsert(dbname, collname, attr string, records []map[string]any) error

Upsert inserts records into provided database/collection and attribute

Jump to

Keyboard shortcuts

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