I want to query data which was inserted by C# mongodriver with polymorhism. The query will be done by Golang driver. Structure of the data is shown below. I want to map _t to structs, in other words, I want to apply polymorhism to record in Go. Is it possible to do it in Golang mongo drivers? The list of structs is below as well.
One record example from mongo collection
{"_id" : "asdasda12312312asdasda",
"structure" : [
{
"_t" : "AObject",
"Text" : "asdasdasda",
"State" : "asdasda"
},
{
"_t" : "BObject",
"Number" : "123",
},
{
"_t" : "CObject",
"Testing" : "Pompeo"
}
]
}
Go Structs
type Data struct{
_id string
Structure []Object
}
type Object interface{
}
type AObject struct {
Text string
State string
}
type BObject struct {
Number string
}
type CObject struct {
Testing string
}
Thanks