Created
October 9, 2015 02:57
-
-
Save foxiepaws/491d773a8fadad712dfa 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
| require 'datamapper' | |
| class Book | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :title, String | |
| property :summary, Text | |
| # associations to other models | |
| belongs_to :author | |
| has n, :taggings | |
| has n, :tags, :through => :taggings | |
| # TODO: write functions to make editlog work. | |
| has n, :editlog | |
| end | |
| class Trope | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :name, String | |
| property :desc, Text | |
| end | |
| class TropeSpoiler | |
| include DataMapper::Resource | |
| property :id, Serial | |
| # tropeid | |
| property :spoiler, Text | |
| end | |
| class Author | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :name, String | |
| property :bio, Text | |
| has n, :books | |
| end | |
| class Tags | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :tag, String | |
| has n, :taggings | |
| has n, :books, :through => taggings | |
| end | |
| class Taggings | |
| include DataMapper::Resource | |
| belongs_to :tag, :key => true | |
| belongs_to :book, :key => true | |
| end | |
| class EditLog | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :type, Integer # 0 is creation, 1 is modified, 2 is deletion | |
| # association for who made this. | |
| property :time, DateTime | |
| property :minor, Boolean, :default => true | |
| property :desc, Text # | |
| property :diff, Text # content of | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment