go – Golang GORM scan to map-ThrowExceptions

Exception or error:

I do some query on my GORM application and right now for scanning row from database is using struct. But the problem is come when I need to do some query that different each other, which I need to create another struct for each query I have.

And actually I don’t care about the data that I got from database, it just forwarded to client. So, for me making struct for each of it will be a lot of work. So I am thinking that if I can scan it to map[string]interface{} or []map[string]interface{}. So is it possible to do it on GORM?

And I also thinking about another thing is when column converted to interface{} what about date? It will be converted to string? (and also for other type like int, long, array, etc)

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *