Home

Awesome

mongoid-tags Build Status

Mongoid::Tags adds a simple tagging system to your Mongoid documents, and allows you to query them using a boolean search syntax.

Installation

In your Gemfile:

gem 'mongoid-tags'

Usage

class Document
  include Mongoid::Document
  include Mongoid::Tags
end

# Documents tagged foo || bar
Document.tagged('foo bar')

# Documents tagged foo && bar
Document.tagged('+foo bar')

# Documents tagged foo, but !bar
Document.tagged('foo -bar')

# Documents tagged foo and bar or baz
Document.tagged('(+foo +bar) baz')

# Documents tagged foo and bar, or foo and baz
Document.tagged('(+foo +bar)(+foo +baz)')

# Chaining calls
Document.where(published: true).tagged('foo').desc(:created_at)

Be sure to checkout test/integration_test.rb for more examples.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

(The MIT license)

Copyright (c) 2012-2016 Mario Uher

See LICENSE.md.