Hi, Nice work!
I've been working in the same problem but I took a slightly different
approach, I would like to know your opinions,
I created a command line tool that generates structs from tables, with
additional convenience methods, like Save()
It's also without reflection and trying to not to be too magichttp://github.com/alfonsodev/yao
This is an example of model
generated by yao command,
The generated code is very simple, doesn't depend on reflect. There is only
one additional struct called query.go,
that allows you to chain And, Or , conditions.
Although it's functional, is still open for design suggestions, for
instance I already receive feedback about returning a slice of interfaces
maybe it's not be the best way.
// UsersWhere returns a query struct, that can chain additional conditions .And, and Or
// At the end Get method of query it's executed but it returns a slice of interfaces
// to be able to work with all tables as it's not posible to know the type you want dynamically
students, error := UM.UsersWhere("Email", "LIKE", "%.edu").Get()// but it could be rework as the following that would return slice of Users in both cases. students, error := UM.UsersWhere("Email", "LIKE", "%.edu").GetUsers() students, error := UM.UsersWhere("Email", "LIKE", "%.edu").Get("Users")
For the moment it only has support for postgresql, adding support for mysql
it's as easy as write the equivalent to the postgres adapter
On Monday, June 1, 2015 at 5:35:57 AM UTC+2, Jaime wrote:
I recently created a tool that generates code to convert sql.Row(s) into
any structs you define. I've used it for my own small project and it worked
well. I was wondering if I could get some feedback from the community about
his approach of working with databases.
The project is github.com/variadico/scaneo. The readme contains usage
info and a quick tutorial.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/d/optout.