jmoiron / modl

golang database modelling library
MIT License
479 stars 48 forks source link

How can I get count(*) with func (*DbMap) Select? #19

Closed dorajistyle closed 10 years ago

dorajistyle commented 10 years ago

Hello, I'm a newbie of Golang. I've modifed https://github.com/coopernurse/gorp#quickstart. And ran it. But I didn't find the way to get count(). How can I get count() with func (*DbMap) Select?

Regards, JoongSeob.

jmoiron commented 10 years ago

Hi JoongSeob,

SelectInt, etc are not implemented in modl. Instead, you should use code like this:

var count int
err := dbmap.Dbx.Get(&count, "SELECT count(*) FROM table;")

For more information on how to use the Dbx handle on dbmap, check out the documentation on sqlx.

dorajistyle commented 9 years ago

Thanks.