Adding custom views with couch_potato and simple_stored?
I'm building a rails app on top of couchdb and decided to try heaps of putato and simple_sorted gems as they seem to add a nice feature above the rest of the apis and put couchdb development on track.
From what I can see, SimlyStored / Couch is working on the couch_potato layer, so as far as I understand, the basic couch_potato functionality should be accessible from a class that includes SimplyStore :: Couch.
However, I was unable to use the view keyword to create custom views in the model containing SimplyStored.
For example, the following code:
Class MyExample
include SimplyStored::Couch
property :name
end
A doc project named _design / myexample will be created which will contain a view named all_documents for the find (..) methods . This is really pretty nice.
However changing the code to
Class MyExample
include SimplyStored::Couch
property :name
view :example, :map => "function(doc) { emit(doc.name, null)}", :include_docs => true, :type => :custom
end
An example with a view name will not be added as I would expect, however I am sure the somwhere point is missing.
So, if anyone has any suggestions for defining additional custom views using these frameworks, I'd really appreciate it.
Thanks,
a source to share
Ok, I really missed something as declaring a view is not enough to create a view. We must explicitly initiate the creation of the view, for example, by updating the class code to:
Class MyExample
include SimplyStored::Couch
property :name
view :example, :map=>"function(doc) { emit(doc.name, null)}",:type => :custom
CouchPotato.database.view MyExample.example
end
a source to share