• Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      It'd be nice to have a way to define a default scope for models. Something that works like <code>default_scope</code> in ActiveRecord:

      <pre><code>class Person
      include Mongoid::Document
      default_scope order_by([:age, :asc])
      end</code></pre>

      Looking at the <code>finders.rb</code> I came up with an experimental implementation of <code>default_scope</code> and uploaded a gist to https://gist.github.com/e0f97c90434c100a6666

      It works for the standard case, but I'm not sure where to add the method and how to test it properly. The fact that the implementation was so easy and this feature hasn't been implemented yet makes me wonder if I'm missing something as well

      I'm willing to implement and test this, but some pointers how and where to do so would be great.

            Assignee:
            Unassigned Unassigned
            Reporter:
            benedikt Benedikt Deicke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: