Simple interfaces for working with basic key-value storage in your Go application https://pkg.go.dev/github.com/annybs/ezdb
|
11 сар өмнө | |
---|---|---|
.github | 11 сар өмнө | |
.gitignore | 11 сар өмнө | |
LICENSE.md | 11 сар өмнө | |
README.md | 11 сар өмнө | |
collection_tester.go | 11 сар өмнө | |
errors.go | 11 сар өмнө | |
go.mod | 11 сар өмнө | |
go.sum | 11 сар өмнө | |
interfaces.go | 11 сар өмнө | |
json.go | 11 сар өмнө | |
key.go | 11 сар өмнө | |
leveldb.go | 11 сар өмнө | |
leveldb_iter.go | 11 сар өмнө | |
leveldb_options.go | 11 сар өмнө | |
leveldb_test.go | 11 сар өмнө | |
memory.go | 11 сар өмнө | |
memory_iter.go | 11 сар өмнө | |
memory_test.go | 11 сар өмнө | |
sort.go | 11 сар өмнө | |
staticcheck.conf | 11 сар өмнө |
This package provides simple interfaces for working with basic key-value document storage in your Go application.
The primary interface in EZ DB is Collection[T]
which reflects a single key-value store. This is analogous to tables in RDBMS, collections in NoSQL databases etc.
Collections use a generic type T
to specify the document type. You can use this to enforce a document schema. This example creates a collection which only accepts Student
documents:
package main
import "github.com/annybs/ezdb"
type Student struct {
Name string
Age int
}
var db = ezdb.Memory[Student](nil)
func main() {
db.Open()
db.Put("annie", Student{Name: "Annie", Age: "32"})
db.Close()
}
Some database backends require marshaling and unmarshaling data. The DocumentMarshaler[T1, T2]
interface allows you to use whatever marshaler suits your needs or the requirements of your chosen database.
The following marshalers are included in EZ DB:
JSON[T]
marshals your data T
to []byte
using encoding/jsonThe following databases are included in EZ DB:
LevelDB[T]
is fast key-value storage on diskMemory[T]
is essentially a wrapper for map[string]T
. It can be provided another Collection to use as a persistence backendEZ DB is intended for simple document storage and can work with any addressable data represented as T
in your Go app.
This makes it unsuited for working with unaddressable types, such as byte arrays, particularly when a document marshaler is involved.
If you want more control beyond what EZ DB offers, it's best to just use the appropriate database software and connector for your needs.
See LICENSE.md