How are they meant to be defined? I found one topic on it dating back
to 2008, so maybe some things have changed in between:
# BEGIN
require 'rubygems'
require 'sequel'
require 'logger'
DB = Sequel.sqlite
DB.loggers << Logger.new(STDOUT)
Sequel::Model.plugin(:schema)
class Foo < Sequel::Model
set_schema do
primary_key :title, :type => :text, :auto_increment => false
end and create_table unless table_exists?
one_to_many :bars
end
class Bar < Sequel::Model
set_schema do
primary_key :name, :type => :text, :auto_increment => false
foreign_key :foo_title, :foos, :type => :text
end and create_table unless table_exists?
many_to_one :foo, :key => :foo_title
end
Foo.insert(:title => 'Baz')
Foo.first.bars
# END
=> SELECT * FROM `bars` WHERE (`bars`.`foo_id` = 'Baz')
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.