Sha256: 1cb0f8e420a7123b609742a38c3067684e4f2431f12c05c441abd3c5caab1384
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'rubygems' require 'dm-core' DataMapper.setup(:default,'sqlite3:test.sqlite3') log = DataMapper::Logger.new(STDOUT, :debug) log.push "==== hello datamapper" class Post include DataMapper::Resource property :id, Serial property :title, String property :body, Text property :created_at, DateTime has n, :comments end class Comment include DataMapper::Resource property :id, Serial property :posted_by, String property :email, String property :url, String property :body, Text belongs_to :post end class Category include DataMapper::Resource property :id, Serial property :name, String end class Categorization include DataMapper::Resource property :id, Serial property :created_at, DateTime belongs_to :category belongs_to :post end class Post has n, :categorizations has n, :categories, :through => :categorizations end class Category has n, :categorizations has n, :posts, :through => :categorizations end # Post.auto_migrate! # Category.auto_migrate! # Comment.auto_migrate! # Categorization.auto_migrate! DataMapper.auto_migrate!
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nosql-tutorial-0.1.1 | lib/public/doc/datamapper/000-sqlite3.rb |