Can DataMapper properties appear in multiple composite indexes?

I found that this issue was discussed in Ticket # 58 DataMapper, apparently, back in 2007, but I can not find how to do this in the latest version (dm-core-0.10.2). I want to define two composite indexes, each of which is partially based on a specific property. I was hoping I could do this ...

class Stat
  include DataMapper::Resource
  property :id,            Serial,
  property :collected_on,  Integer #yyyyMMddhhmm
  property :measure,       Integer
  property :dimension_one, Integer
  property :dimension_two, Integer
  property :source_id,     Integer
  index [:collected_on, :dimension_one, :dimension_two]
  index [:source_id, :collected_on]
end

What is the right way to do this?

+3
source share
1 answer

You can do it:

class Stat
  include DataMapper::Resource
  property :id,            Serial,
  property :collected_on,  Integer, :index => [ :index_one, :index_two ]
  property :measure,       Integer
  property :dimension_one, Integer, :index => :index_one
  property :dimension_two, Integer, :index => :index_one
  property :source_id,     Integer, :index => :index_two
end

, . Array Symbol, , true, , , .

+2

Source: https://habr.com/ru/post/1730112/


All Articles