modl icon indicating copy to clipboard operation
modl copied to clipboard

SelectAll support

Open ferhatelmas opened this issue 10 years ago • 2 comments

Is there a plan to support SelectAll ?

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

Or how welcome are you for it?

ferhatelmas avatar Jun 03 '15 09:06 ferhatelmas

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.

jmoiron avatar Jun 03 '15 16:06 jmoiron

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!

ferhatelmas avatar Jun 04 '15 11:06 ferhatelmas