Schema API and quad labels


#1

I would like to provide a way for different users of an application to have facts they add, modify and delete walled off in different “organizations,” and I was going to use the quad label for this. I’ve been using schema.WriteAsQuads to write annotated structs to Cayley as a set of quads, but I’m having difficulty finding a way to supply the label part of the quad to this or a related method. Is there a pointer to a Golang file or to documentation that will clarify this?


#2

Looking over schema.go, I gather that the label is not currently supported when using the schema API to write to the store; e.g.,

I’ve taken a different approach and am writing the struct as a series of quads and including the label as the fourth argument:

func (conn *CayleyConnection) CreateLink(orgId quad.IRI, node *Link) error {
	return conn.Do(func(tx *graph.Transaction) {
		tx.AddQuad(quad.Make(node.ResourceID, quad.IRI("rdf:type"), quad.IRI("di:link"), orgId))
		tx.AddQuad(quad.Make(node.ResourceID, quad.IRI("di:url"), node.URL, orgId))
		tx.AddQuad(quad.Make(node.ResourceID, quad.IRI("di:title"), node.Title, orgId))
		addParentTopics(tx, orgId, node)
	})
}

As long as all of the required fields are written in this way, the struct can be read using the schema API without issue.


#3

Feel free to open an issue about similar problems directly on Github - it will be addressed faster :slight_smile:

You will now be able to specify a quad label in v0.7.4 that will be released soon (see schema.Config.Label in 1a0c7cb).