Created
December 22, 2009 03:56
-
-
Save arbales/261484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Table | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
# Relationship to the join table. | |
has n, :tableBookings | |
# Defines that Table has bookings in :tableBookings on the :booking named relationship. (a) | |
has n, :bookings, :through => :tableBookings, :via => :booking | |
end | |
class Booking | |
include DataMapper::Resource | |
property :id, Serial | |
has n, :tableBookings | |
# Defines that Booking has tables in :tableBookings on the :booking relationship. (b) | |
has n, :tables, :through => :tableBookings, :via => :table | |
belongs_to :employee | |
belongs_to :customer | |
end | |
class TableBooking | |
include DataMapper::Resource | |
property :serial, Serial | |
property :table_id, Integer, :min => 1 # (a) | |
property :booking_id, Integer, :min => 1 # (b) | |
belongs_to :table # (a) | |
belongs_to :booking # (b) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment