A getting started thing

I did a few changes. For instance in the Post type.

type Post struct {
	Id         uint64  `json:"_uid_,omitempty"`
	AuthorId   string  `json:"author_id,omitempty"`
	ParentPost *Post   `json:"parent_post,omitempty"`
	Thread     *Thread `json:"thread,omitempty"`
	Title      string  `json:"title,omitempty"`
	Body       string  `json:"body,omitempty"`
}

I’m not sure if this Thread is needed here in Post but it’s good to have a reference to the thread the post belongs to.

And I also changed Thread because it would seem that this makes more sense, in a practical sense:

type Thread struct {
	Id        uint64  `json:"_uid_,omitempty"`
	Forum     *Forum  `json:"forum,omitempty"`
	FirstPost *Post   `json:"first_post,omitempty"`
	LastPost  *Post   `json:"last_post,omitempty"`
	Posts     []*Post `json:"posts,omitempty"`
}

So the Thread’s title is determined by a query for the first Post and there’s the last post, aka the latest reply to the thread (so you can mouseover skim the original post’s content and the last post’s content, see if it’s worth reading etc.).
Likewise there’s a Forum reference (to skim other thread titles in the forum or w/e).

So the question is … “relationships”.
a Thread belongs to a Forum (One), a Forum can have many Threads (ToMany)
a Post belongs to a Thread (One), a Thread can have many Forums (ToMany)

Forum > Thread OneToMany (aka []*Thread)
Thread > Forum ManyToOne (aka forum_id)

Thread > Post OneToMany ( aka []*Post)
Post > Thread ManyToOne ( aka thread_id)

Why not ManyToMany? Because One Post can only belong to One Thread.

But how do you do that in Go and dgraph?

https://tour.dgraph.io/intro/3/ says

  schema {
    name: string @index(exact, term) .
    age: int @index(int) .
    friend: uid @count .
  }

So friend is a uid of a node with the @count. Oh right, I forgot, I’d like to know how many Threads are in a Forum and how many Posts are in a Thread. Is anything special required on the Go side?

What is recommended?
Let’s take the Thread Post relation and structs.
Would it make more sense to have a ThreadId uint64 json:"thread_id" in Post or is Thread *Thread json:"thread" good enough?