Closed 4e6963 closed 6 years ago
Yes, but currently you need to do a bit of work. Either use the content API to get the resource via HTTP, or parse the URI to get the type and ID and get the value directly from the database using the system/DB
package.
I plan to provide a method in the db package to resolve the reference URI more easily, but am short on time recently.
Thank you for the fast response.
This solution works for me. I hope I will find time in the next weeks, to do a pull request with a general solution.
// No error handling
func (d *Document) String() string {
companyQuery := d.Company
url, _ := url.Parse(companyQuery)
urlQuery := url.Query()
query := urlQuery.Get("type") + ":" + urlQuery.Get("id")
bytes, _ := db.Content(query)
company := Company{}
json.Unmarshal(bytes, &company)
return d.Title + " from " + company.Name
}
Great! I'll look forward to it. If I get a chance to start, I'll be sure to ping you here so we don't overlap work. Thanks :)
I tried to show parent content's data in string(). But it doesn't resolve the URL
func (d *Document) String() string { return d.Title + " from " + d.Company }
Shows this:Is there a way to do this?