JP.
JP.

Reputation: 5594

Creating filters with couchrest_model

My couchrest_model class has a design section which defines a filter, but they never appear.

class MyDoc < CouchRest::Model::Base
  property :my_key, String

  design do
    filter 'my_filter', "function(doc) {return (doc['my_key'] == 'value');}"
  end
end

If I require the file that contains this in IRB, even if I create a few documents, the filter is never written. What do I need to call to do this?

Thanks.

Upvotes: 1

Views: 100

Answers (1)

joscas
joscas

Reputation: 7674

I'm not sure couchrest_model supports filters. You could try saving the filter directly with couchrest:

@db = CouchRest.database("http://127.0.0.1:5984/my_db")
@db.save_doc({
    "_id" => "_design/my_filters", 
    :filters => {
      :my_filter => {
        "function(doc) {return (doc['my_key'] == 'value');}"
        }
      }
    })

Upvotes: 1

Related Questions