alevy / postgresql-orm

An Haskell ORM (Object Relational Mapping) and migrations DSL for PostgreSQL.
http://simple.cx
GNU General Public License v3.0
78 stars 12 forks source link

add variant of 'findAll' for pagination #6

Closed tvh closed 9 years ago

tvh commented 9 years ago

To make 'findAll' more useful outside a debugging environment, I added an option to use it with pagination.

alevy commented 9 years ago

Some questions about this:

  1. You can do this using the DBSelect module, for example https://github.com/alevy/mappend/blob/master/Blog/Controllers/PostsController.hs#L45 . Does it make sense to just implement in terms of that module, since it already exposes a safer interface to "offset" and "limit" keywords?
  2. If not (1), I'm wondering if there is a more descriptive name that isn't combersome. The problem with just adding a "" at the end of a function name is that it's not at all clear what the extension is to the original function, especially with something as rich as SQL. Perhaps something likefindPage`?
  3. I understand that the parameter is a Maybe so we can easily re-use it from findAll, but two separate parameters seems more meaningful, IMO. I think it might be better in this case to just duplicate the code but have more a meaningful type signature.
tvh commented 9 years ago

Oh, thanks. I think I just missed that. In that case it may make more sense to just use that and not define a special function just for this.

alevy commented 9 years ago

OK. If you find yourself using it a lot and find it cumbersome, we should probably find a way to sensibly make a combinator for it.