views:

77

answers:

0

Hi,

I'm trying to use the Friendly ORM in combination with Sinatra for a small side project, but I'm having trouble implementing a DISTINCT type pattern.

Here is an example of the model class:

class Game
  include Friendly::Document

attribute :user_id, Friendly::UUID
attribute :friendly_team, String
attribute :opposing_team, String
attribute :winning_side, Integer
attribute :force, Integer

indexes :user_id
indexes :force, :user_id

named_scope :leaders, :order! => :force.desc, :limit! => 25, :distinct => :user_id

I'm hoping that the leaders scope should use the :force / :user_id index, but when attempting Game.leaders.all I get a Friendly::MissingIndex exception.

Help appreciated, thanks for taking the time.