Schema tags

schema

#1

Hello good day,

I just want to ask, where I can find all the valid tags for creating a schema?

I will appreciate any advice will come.

Thanks


#2

Hi @zer09,

What do you mean by “all valid tags”?


#3

hi @dennwc,

On your example on hello_schema you define @type, @id, and the quad tags, other than that what are the available tags we can use?


#4

You may notice that JSON tags and quad tags are used nearly interchangeably in the example:

type Person struct {
	rdfType struct{} `quad:"@type > ex:Person"`
	ID      quad.IRI `json:"@id"`
	Name    string   `json:"ex:name"`
	Age     int      `quad:"ex:age"`
}

Thus, if you have a struct annotated with JSON tags, schema library will use them as predicate names. It will ignore all other tags like bson or proto.

Second things to note is that quad tags may specify the direction of the link (quad:"field < *). This way you can specify edges that go from some other node to this one.

Next, there are only 2 special cases in these tags: @type that is mapped to <rdf:type>, and @id that is mapped to the node itself. You can use any other predicate name in the tags, and it will be mapped from name to <name>. You can also use namespaces for these predicates: my:field -> <my:field>. To define a full namespace name you can use voc.Register function.

In general, I would recommend to play with this example by changing few struct tags and seeing how the output of WriteAsQuads changes.


#5

Thank you for the explanation, I will try to play with it. Actually I am still learning how to use graph database.