Best ORM for Golang and their framework like Revel and Martini

7,607 views
Skip to first unread message

Pravin Mishra

unread,
Mar 8, 2014, 3:30:23 PM3/8/14
to golan...@googlegroups.com
I'm searching for an ORM that make Relations, callbacks, Migrations, Scopes, Validation effort-less and use conventions like Rails ActiveRecord. I find gorp, hood, qbs, jet, beedb, gosexy, gorm on Revel official site but because of complexity of an e-commerce database, I need to decide which ORM will work best for me. Please help me to choose best one.

Nate Finch

unread,
Mar 8, 2014, 3:37:13 PM3/8/14
to golan...@googlegroups.com
I find sqlx (https://github.com/jmoiron/sqlx) to be a really great way to get stuff into and out of a database.  I actually don't really like ORMs, since they tend to make the easy stuff easier and the hard stuff harder.  The more complex your database, the less likely it is that ORMs will work for you, in my experience.  I think you tend to spend as much time learning and fighting with the ORM as you would just writing some queries by hand.

Andrew Gallant

unread,
Mar 8, 2014, 8:28:44 PM3/8/14
to golan...@googlegroups.com
For database migrations, you may find https://github.com/BurntSushi/migration useful. It will only work properly with databases that have full transaction support for schema changes (e.g., Postgres and SQLite but not MySQL).


On Saturday, March 8, 2014 3:30:23 PM UTC-5, Pravin Mishra wrote:

Philippe Lafoucrière

unread,
Mar 11, 2014, 11:43:05 AM3/11/14
to golan...@googlegroups.com
On Saturday, March 8, 2014 9:30:23 PM UTC+1, Pravin Mishra wrote:
I'm searching for an ORM that make Relations, callbacks, Migrations, Scopes, Validation effort-less and use conventions like Rails ActiveRecord. I find gorp, hood, qbs, jet, beedb, gosexy, gorm on Revel official site but because of complexity of an e-commerce database, I need to decide which ORM will work best for me. Please help me to choose best one.

Coming from ruby on rails (and therefore, ActiveRecord), I find Gorm to be the closest in terms of features and syntax. 
The lib still lacks migrations support (even-though automigrations are supported), but you can mix it with goose (https://bitbucket.org/liamstask/goose) easily.

Alex

unread,
Mar 14, 2014, 12:07:49 AM3/14/14
to golan...@googlegroups.com
Hi, I use upper.io It's ex goosey/db. But It can convert structs to/from DB.

Konstantin Ryabov

unread,
Nov 7, 2014, 8:01:11 AM11/7/14
to golan...@googlegroups.com
upper.io  spent ~10 sec to connect to mysql. 
database/sql  do it in a moment.

пятница, 14 марта 2014 г., 8:07:49 UTC+4 пользователь Alex написал:

m...@pangea.vc

unread,
Jun 8, 2019, 2:38:05 PM6/8/19
to golang-nuts
Are you kidding? without ORMs you can't model relationships.  People choose languages like religion, but seriously look at the power of Rails' ActiveRecord.  It's amazing.

Andrew Pillar

unread,
Jun 9, 2019, 2:25:46 PM6/9/19
to m...@pangea.vc, golang-nuts
I made a comment about a similar topic on an HN thread, about
ActiveRecord style ORMs in Go.

> Personally I think an active record style ORM for Go like gorm is a
> poor fit for a language that doesn't come across as inherently OOP.
> Going through some of the documentation for gorm, it seems to rely
> heavily on method chaining which for Go seems wrong considering how
> errors are handled in that language. In my opinion, an ORM should be
> as idiomatic to the language as possible.

> I've used sqlx[1] before, and it feels pretty idiomatic to Go. You tag
> your structs with their respective database columns, write up a
query, > and hand it to sqlx to perform the deserialisation of the data.
I've
> also come across squirrel[2] too, though I haven't used it, it does
> look rather interesting.

> [1] - https://github.com/jmoiron/sqlx

> [2] - https://github.com/masterminds/squirrel

You're right, ORMs do help with modelling data, but I think the
ActiveRecord approach is the wrong way of going in regards to Go.

Also, regarding database migrations in Go, I made a simple migration
tool for SQL migrations. You simply write plain SQL scripts, and these
get performed and logged against the database. Right now it supports
SQLite, MySQL, and PostgreSQL, and you can check it out here:
https://github.com/andrewpillar/mgrt.

Andrew Pillar

unread,
Jun 9, 2019, 2:25:54 PM6/9/19
to m...@pangea.vc, golang-nuts
I made a comment about this on an HN thread about ORMs in Go.

> Personally I think an active record style ORM for Go like gorm is a
poor fit for a language that doesn't come across as inherently OOP.
Going through some of the documentation for gorm, it seems to rely
heavily on method chaining which for Go seems wrong considering how
errors are handled in that language. In my opinion, an ORM should be as
idiomatic to the language as possible.

> I've used sqlx[1] before, and it feels pretty idiomatic to Go. You
tag your structs with their respective database columns, write up a
query, and hand it to sqlx to perform the deserialisation of the data.
I've also come across squirrel[2] too, though I haven't used it, it does
look rather interesting.

> [1] - https://github.com/jmoiron/sqlx

> [2] - https://github.com/masterminds/squirrel

I agree with you when you say that ORMs help with modeling relations.
However I think the following the design of ActiveRecord is the wrong
approach to take when it comes to ORMs in Go.

Also, regarding database migrations in Go. I made a simple tool for
performing database migrations. It allows you to write plain SQL, and
have these SQL scripts be performed against the database an logged.
Right now it supports SQLite, MySQL, and PostgreSQL, you can find it at
https://github.com/andrewpillar/mgrt.
Reply all
Reply to author
Forward
0 new messages