Есть один пример, подобный этому:
class Book
include MongoMapper::Document
key :title
key :author_ids, Array
many :authors, :in => :author_ids
end
class Author
include MongoMapper::Document
key :name
end
Это эквивалентно
class Book
include MongoMapper::Document
key :title
many :AuthorHasBook
end
class AuthorHasBook
include MongoMapper::Document
key :written_time
belongs_to :book, :class_name => "Book"
belongs_to :author, :class_name => "Author"
end
class Author
include MongoMapper::Document
key :name
many :AuthorHasBook
end
Что лучше? Я думаю, если мне нужно добавить несколько полей для "реляционной" сущности, я должен использовать 2-е решение?
Заранее спасибо!