[Nitro] composite primary key

George Moschovitis george.moschovitis at gmail.com
Thu Aug 4 09:34:31 EDT 2005


> class Document
>   property :volume, String
>   property :accession, String
>   property :path, String
> 
>   set_primary_key :volume, :accession
> 
>   has_many :pages, Page
> end

At the moment you can do:

class Document
  property :volume, String
  property :accession, String
  property :path, String
  sql_index :volume, accession

  has_many :pages, Page

  def self.[](volume, accession)
     Document.find(:condition => "volume=#{volume} AND accession=#{accession}")
  end
end

then you can use the proposed api:

doc = Document[vol, acc]

Is this all you want? Some new features of 0.22.0 will make this much
more transparent.

regards,
George.




-- 
http://www.gmosx.com
http://www.nitrohq.com
http://www.joy.gr




More information about the Nitro-general mailing list