I couldn't find an example at datamapper.org /docs for a parent child relationship.
After a little searching, I found the answer in the integration tests. Here is the example:
class Node
include DataMapper::Resource
def self.default_repository_name
ADAPTER
end
property :id, Integer, :serial => true
property :name, String
has n, :children, :class_name => 'Node', :child_key => [ :parent_id ]
belongs_to :parent, :class_name => 'Node', :child_key => [ :parent_id ]
end
Hope that helps someone else.
6 comments: