What is the difference between RootID and ParentId about Post ?

type Post struct {
	Id         string `json:"id"`
	CreateAt   int64  `json:"create_at"`
	UpdateAt   int64  `json:"update_at"`
	EditAt     int64  `json:"edit_at"`
	DeleteAt   int64  `json:"delete_at"`
	IsPinned   bool   `json:"is_pinned"`
	UserId     string `json:"user_id"`
	ChannelId  string `json:"channel_id"`
	RootId     string `json:"root_id"`
	ParentId   string `json:"parent_id"`
	OriginalId string `json:"original_id"`

Hello, @naichadouban

Based on the conversation I had with the lead engineer, I can confirm that:

  • RootId is the identifier of the first post in a thread
  • ParentId is a legacy column and it is no longer in use
  • OriginalId is to keep track of the original post before it was edited

Shout out to @elias for the confirmation. :slight_smile:

thank you! :pray: :pray:

Is the RootId/ParentId for mapping a post that is a comment (that is a reply to another post) to the post being replied to?

It seems Mattermost uses CreateAt as a Primary key in the database, however RootId/ParentId are alpha numeric. How can I get the CreateAt of the post that is the post the comment/reply is replying to?

Thank you

How can I do it using MySQL?

RootId and ParentId are related, but they serve different purposes in Mattermost threads. RootId identifies the root post of the thread, so replies to the same thread normally point back to the same root post. ParentId identifies the specific post that the current post is replying to. So for a simple one level reply, they may look similar, but they arent interchangeable. RootId is mainly useful for finding the whole thread, while ParentId tells you the immediate parent of that particular post.