lundi 10 août 2015

Resolve the struct passed to a function in Runtime

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.





Aucun commentaire:

Enregistrer un commentaire