I have the below interface that implements a simpler Active Record Like implementation for my persistent layer.
type DBInterface interface {
FindAll(collection []byte) map[string]string
FindOne(collection []byte, id int) map[string]string
Destroy(collection []byte, id int) bool
Update(collection []byte, obj map[string]string ) map[string]string
Create(collection []byte, obj map[string]string) map[string]string
}
The application has different collection's that it talks to and different corresponding models. I need to be able to pass in a dynamic Struct , instead of a map for the value obj ( ie. Update , Create Signatures )
I can't seem to understand how to use reflection to resolve the Struct , any guidance would help.
More details on what I am trying explain :
Consider the below snippet from mgo example from https://labix.org/mgo
err = c.Insert(&Person{"Ale", "+55 53 8116 9639"},
&Person{"Cla", "+55 53 8402 8510"})
When we insert data to the collection , we do a &Person I want to be able to pass in this bit &Person{"Ale", "+55 53 8116 9639"} but the method receiving the would only know it in the Run time. Because it could be a Person , Car , Book etc Struct depending on the func calling the method
use reflection to resolve the Struct; can you show what you're trying to achieve?c.Insert. Do you need to operate on these structs yourself too?