has_many association based on Views
Reported by Oleg Andreev | April 28th, 2008 @ 02:42 AM | in 0.0.3
Article = Meta.new do
has_many :comments
end
BlogPost = Meta.new do
has_many :comments
end
produces =>
View.define(:name => "has_many_comments") do |v|
def v.map(uuid, doc)
[ [ [doc['belongs_to'], doc['created_at']], doc ] ] if doc.is_a? Comment
end
end
Comment.new(... :belongs_to => some_article )
some_article.comments # => list of all comments
This view is compatible with all the comment containers, defined at any time.
Comments and changes to this ticket
-
Yurii Rashkovskii April 28th, 2008 @ 02:44 AM
- → Assigned user changed from to Yurii Rashkovskii
-
Yurii Rashkovskii April 28th, 2008 @ 02:49 AM
While it might be interesting to do a single view for comments, I think we should pay attention to this kind of special cases later — and as for now we only need to create a view per association.
-
Yurii Rashkovskii April 28th, 2008 @ 02:59 AM
- → State changed from new to open
started views-based-associations branch (http://github.com/yrashk/stroked...)
-
Yurii Rashkovskii April 28th, 2008 @ 11:34 AM
- → State changed from open to duplicate
Duplicate to #15
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
StrokeDB is an embeddable distributed document database written in Ruby
