-
Notifications
You must be signed in to change notification settings - Fork 25
Add associations #6
Copy link
Copy link
Open
Description
We should add association support:
class Post < YamlRecord::Base
belongs_to :episode
# auto-adds `property :episode_id, Integer`
endThis adds a episode_id integer foreign key reference. You can then do stuff like:
p = Post.new
p.episode = Episode.find(5)
p.save
p.episode # => <Episode id=5>
p.episode_id # => 5or:
p = Post.new
p.episode_id = 5
p.save
p.episode # => <Episode id=5>
p.episode_id # => 5Also adds embeds_many support:
class Post < YamlRecord::Base
embeds_many :users
# adds property :user_ids, Array, Integer
endand allows for:
p = Post.new
p.user_ids = "1,2,3"
p.save
p.users # => [<User 1>, <User 2>, <User 3>]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels