| Class | CouchPotato::View::PropertiesViewSpec |
| In: |
lib/couch_potato/view/properties_view_spec.rb
|
| Parent: | CouchPotato::View::ModelViewSpec |
A view to return model instances with only some properties poulated by searching its properties, e.g. for very large documents where you are only interested in some of their data
example:
view :my_view, :key => :name, :properties => [:name, :author], :type => :properties
# File lib/couch_potato/view/properties_view_spec.rb, line 8
8: def map_function
9: "function(doc) {
10: emit(#{formatted_key(key)}, #{properties_for_map(properties)});
11: }"
12: end
# File lib/couch_potato/view/properties_view_spec.rb, line 14
14: def process_results(results)
15: results['rows'].map do |row|
16: klass.json_create row['value'].merge(:_id => row['id'])
17: end
18: end