I found this neat little embeddable DB and wanted to use it in go.
Make sure you have the dev headers of ejdb.
cgo will be looking for these header files during compilation:
- stdlib.h
- ejdb2/ejdb2.h
- ejdb2/iowow/iwkv.h
go get github.com/memmaker/go-ejdb2/v2
package main
import (
"fmt"
"github.com/memmaker/go-ejdb2/v2"
)
func main() {
db := ejdb2.EJDB{}
db.Open("test.database")
defer db.Close()
db.EnsureCollection("users")
id := db.PutNew("users", `{"name": "John", "age": 30}`)
fmt.Println("New record ID:", id)
user := db.GetByID("users", id)
fmt.Println(user)
}
Please refer to the ejdb2 documentation for more information: