jmoiron / modl

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

SelectAll support #37

Open ferhatelmas opened 9 years ago

ferhatelmas commented 9 years ago

Is there a plan to support SelectAll ?

var users []User
err := dbm.SelectAll(&users)

Or how welcome are you for it?

jmoiron commented 9 years ago

I haven't planned on it. It should be trivial to do with dbm.TableFor(User{}).TableName and some simple sql. I think I'd have to wait and see for the patch, because this is slightly tricky and it's fairly easy to just write the query. The advantage of SelectAll would be that you could do it with an unknown type.

I don't think it's necessary to provide a function for any old SQL that you could produce easily. Maintaining a smaller API has its own benefits. CRUD is repetitive and in some cases easy to get wrong, so those kinds of helpers are okay. I am open to arguments in favor, though.

ferhatelmas commented 9 years ago

I agree with you. However, we have a kind of policy not to have any SQL in code. We're reading queries into one holder in setup and use it. Then, it becomes a bit repetitive even for a simple query. Please give a look and let me know if it's good. Thank you!