So, in the app, I do something like this:
Item.all(:order => sort).select { |item| item.to_s.downcase.include? search.to_s.downcase }
Where sort
is an array of fields to order by. By default (with lazy-loading enabled), the query output from DataMapper looks like the following (on a table of 8601 rows):
~ (0.142849) SELECT "id", "created_at", "updated_at" FROM "items" ORDER BY "artist", "title", "year", "label", "format"