You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some cases I need to extend my standard models with computed data. E.g. display information about the existence of some DB values in the UI. I do this by creating an extended model via type embedding like so:
queryConnection:=DBConnectionqueryConnection=queryConnection.Joins("left join document_fulltexts on documents.id = document_fulltexts.document_id")
queryConnection=queryConnection.Where(`"documents"."user_id" = ?`, userID)
queryConnection=queryConnection.Select(
`"documents"."user_id", "documents"."name", CASE WHEN "document_fulltexts"."fulltext" IS NOT NULL THEN TRUE ELSE FALSE END AS "fulltext_exists"`,
)
documents:= []DocumentListEntry{}
queryConnection.Table("documents").Scan(&documents)
This is the error I get:
[error] failed to guess DocumentFulltext's relations with DocumentListEntry's field DocumentFulltext 1 g false
How do I need to construct the extended model to make this work?
Is this approach recommended at all? Whats the best-practice here? Any alternatives I should consider?
Thx!
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#62
Description
For some cases I need to extend my standard models with computed data. E.g. display information about the existence of some DB values in the UI. I do this by creating an extended model via type embedding like so:
My query then looks like this:
This is the error I get:
How do I need to construct the extended model to make this work?
Is this approach recommended at all? Whats the best-practice here? Any alternatives I should consider?
Thx!
The text was updated successfully, but these errors were encountered: