Scoped aggregation?
mattiassvedhem opened this issue · 0 comments
mattiassvedhem commented
I've wanted to do something like this
class Post
include Mongoid::Document
include Mongoid::TaggableWithContext
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
field :state
taggable
end
Then to be able to do:
Post.create(state: 'published', tags: 'coffeescript')
Post.create(state: 'published', tags: 'ruby')
Post.create(state: 'unpublished', tags: 'java')
Post.where(state: 'published').tags
=> ['ruby', 'coffeescript']
Any ideas on how to implement?