DEV Community

Malik Benkirane
Malik Benkirane

Posted on

surrealdb driver github.com/4sp1/surrealhigh

❓Open-Source
❓Side-Project
❓SurrealDB driver

👤 Surreal High "Coming Out"

Open Source Side Project

Higher level interface to the amazing SurrealDB Rusty DB engine featuring NoSQL, GraphDB, sqlDB with an original query language with permissions and more. They finally release the production edition.

I think Golang interface is lacking behind so I wrote a very handcrafted layer above the existing Go driver to make integrations and tasks easier. Indeed, this is a little trick to generate types for all of the data structures fields you would like to work with. At the moment support is limited and I already alpha tested it with 2 other side projects where I wanted to try a little more SurrealDB. Of course I have more projects to come so this will make the overall product better.

Also there is very basic and incomplete query constructors but it should be seamlessly easy for you to start a discussion so we could get it done together!

Looking forward to your feedback,
Back to you!

Malik

PS

❓Techinality
❓Usability
❓Underground

👤 Install

https://github.com/4sp1/surrealhigh/commit/054984e9ac31

The link would get you to the version you should use

go install ./cmd/sh-gen-types
Enter fullscreen mode Exit fullscreen mode

then in the package for your surrealdb adapter define some struct and for example prepose it with

👤 Use

//go:generate sh-gen-types -doc=myDoc -pkg=mysdbdriver -o my_doc.sdb.gen.go
type myDoc struct{
//... non strictly typed doc
}
Enter fullscreen mode Exit fullscreen mode

👤 Hack

also have a look at the few following flags and meanings

var (
    doc = flag.String("doc", "", "comma-separated list of doc struct names; must be set")
    pkg = flag.String("pkg", "", "destination package")
    out = flag.String("o", "", "destination file .go")
)
Enter fullscreen mode Exit fullscreen mode

from https://github.com/4sp1/surrealhigh/blob/054984e9ac3130d4326f608351d316c88f772ac0/cmd/sh-gen-types/main.go

the whole thing is backed with some template generator with some good and bad sides but it was worth trying and that might happen again:

👤 Dig

// :D
import "github.com/4sp1/surrealhigh/templates/jennifer"
Enter fullscreen mode Exit fullscreen mode

🏁 We're done! It's amazing if you get done to the line

🎪🎪🎪

Top comments (0)