Dgman - Dgraph Schema Manager and Helper


(Wildan Maulana Syahidillah) #1

Hey guys, we want to inform about a library we created for a more rapid development using Dgraph.

Dgman is a schema manager for Dgraph using the Go Dgraph client (dgo), which manages Dgraph schema and indexes from Go tags in struct definitions

Features

  • Create schemas and indexes from struct tags.
  • Detect conflicts from existing schema and defined schema.
  • Autoinject node type from struct.
  • Field unique checking (e.g: emails, username).
  • Query helpers.

We are a startup that is looking to use Dgraph in production, and planning to release some time next year.

This is our first open source project, so some heavy criticism are welcome :wink:. Thank you and we hope this library is useful for the community.


#2

Very cool, I’d appreciate if you bumped the thread if/when you add support for deleting the data. I’ve always found the process of deleting a node and all its edges to be the most frustrating part, so I’d be curious to see how you would handle it (:


(August Hell) #3

I used this library the last days for getting a mysql database converted to dgraph and it helped me a lot.
For rapid devolpment of a new project, it would be cool if dgman would able to mutate the schema, maybe with another function or a non-default option to do so. If you come from a sql world like me, creating relations like 1:n, n:n in dgraph have mutliple ways to do it :smile: . So designing the data model I often changed just the index option like term/hash or adding @reverse.
Another thing related to the data modeling: Having a lot of tables to convert and getting errors back in some cases with no mention to the source (eg protocol errors), I ended up with doing CreateSchema for every node type extended with info about it.
Despite of this small isues, Dgman was easy to use for me and I think it’s a good start up tool for getting a new project to run, thank you :wink:


(Wildan Maulana Syahidillah) #4

@tlmichael Thanks! yes, deleting is quite cumbersome, still figuring out how to make it simple.

@AugustHell Thanks! Great to know this library is of help.

Yeah, we thought of adding for updating the schema, the first doubt was for indexes, an update would require reindexing, we had troubles with those before. Maybe, when there is little data it would not be a problem. We’ll add it probably.

Can you share what protocol errors did you get? Thanks.


(August Hell) #5

Here it is:
“rpc error: code = Unknown desc = Undefined Type”

happens when you try to create a schema with a 1:1 relation (which is a issue and not supported), like:

type Webproject struct {
	UID    string `json:"uid,omitempty"`
	Name   string `json:"webproject.name,omitempty" dgraph:"index=hash"`
	Server string `json:"webproject.server,omitempty" dgraph:"index=hash"`
	IP     string `json:"webproject.ip" dgraph:"index=hash"`
	Domain Domain `json:"webproject.domain"`
}

“Keyboard not found, press any key to continue…” :grin:


(Wildan Maulana Syahidillah) #6

Just released v0.4.1 that supports updating schema index with the MutateSchema function. We added a workaround for the above protocol errors by parsing field with Struct types to uid, just a fallback though, as you said with 1:1 relations, I agree that it is not supported.


(August Hell) #7

Nice, thank you, that is helpful :wink:


(Wildan Maulana Syahidillah) #8

Hey guys, we released a new version that adds delete helpers using a query. Check it out :wink: