You can clone with
HTTPS or Subversion.
I have found that in simply_stored/lib/simply_stored/couch/finders.rb there is a :first method implemented, so I can fetch the first record of that type. Working.
But I am missing a :last method allowing me, to get the last record ...
should be something like
as the first query is made via
CouchPotato.database.view(all_documents(:limit => 1)).first
it seems that a performant approach has to look different for last as for first as we cannot use that :limit => 1 here
Yrah, it would have to look different, but that's not hard to achieve with CouchDB, as you can tell it to walk the view's b-tree backwards. I'll look into it.
hey matt, I just found out one way of achieving this MyModel.last thing ... I am not sure whether there is a more generic method, but If you specify a view for the model like
view :latest_view, :key => :created_at, :descending => true, :limit => 1
this would return the last Document
I just found out one more option ... without the need to define a view inside the model
if with_deleted || !soft_deleting_enabled?
CouchPotato.database.view(all_documents(:limit => 1, :descending => true)).first
:key => nil, :limit => 1, :descending => true)).first