Sinatra, Mongoid 3
There 4 models: User, Book, FavoriteBooks, ReadBooks, NewBooks
. Each user has their list of the favourites, read and new books. A book belongs to a list. But it's also possible to request an information about any book which means books should not be embedded into FavoriteBooks, ReadBooks, NewBooks
.
The part of the scheme:
class Book
include Mongoid::Document
belongs_to :favourite_books
belongs_to :read_books
belongs_to :new_books
end
class FavoriteBook
include Mongoid::Document
has_many :books
end
#.... the same for ReadBooks and NewBooks
class User
include Mongoid::Document
# what else?
end
It seems like I missed something.
What should I do to make a user "contain" the lists of FavoriteBooks, ReadBooks, NewBooks
? Should I use one-to-one relationship?