I want a DataFile to have at most one MessageDigest of a certain code.
I've tried a bunch of combinations of :key and :unique_key etc but i
cant seem to get it right.

if i were to do this in a SQL DDL i'd make data_file_id and code a
composite key. how can i make it work in datamapper?

example models:

class DataFile
  include DataMapper::Resource
  property :id, Serial, :key => true
  property :contents, Text
  has 0..n, :message_digests
end

class MessageDigest
  include DataMapper::Resource
  property :code, Enum[:md5, :sha1, :crc32]
  property :value,  String, :required => true, :length => 255
  belongs_to :data_file
end

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to