使用 couch_potato 和 simple_stored 添加自定义视图?
我正在 couchdb 之上构建一个 Rails 应用程序,并决定尝试 couch_potato 和 Simply_stored gems,因为它们似乎在其余 api 之上添加了一个不错的功能集,并将 couchdb 开发置于“轨道上”。
据我所知,SimlyStored/Couch 在 couch_potato 层之上工作,因此根据我的理解,基本的 couch_potato 功能应该可以从包含 SimplyStored: 的类中访问: 长椅。
但是,我无法使用 view 关键字在包含 SimplyStored 的模型中创建自定义视图。
例如,以下代码:
Class MyExample
include SimplyStored::Couch
property :name
end
将生成一个名为 _design/myexample 的设计文档,其中包含一个名为 all_documents 的视图,用于 find(..)< /strong> 方法。这确实是非常好的。
然而,将代码更改为
Class MyExample
include SimplyStored::Couch
property :name
view :example, :map => "function(doc) { emit(doc.name, null)}", :include_docs => true, :type => :custom
end
不会像我预期的那样添加名为 example 的视图,但我肯定在某个地方遗漏了一点。
因此,如果有人对如何使用这些框架定义其他自定义视图有一些建议,我将非常感激。
谢谢,
I'm building a rails app above couchdb and decided to try the couch_potato and simply_stored gems as they seem add a nice feature set above the rest api and put the couchdb development 'on the rails'.
From what I can see SimlyStored/Couch works above the couch_potato layer, so from my understanding, the basic couch_potato features should be accessible from within a class that includes SimplyStored::
Couch.
However I was unable to use the view keyword in order to create custom views in a model that includes SimplyStored.
For instance, the following code :
Class MyExample
include SimplyStored::Couch
property :name
end
Will generate a design doc named _design/myexample that will contain a view named all_documents be used for the find(..) methods. This is indeed very 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
Won't add a view named example as I would expect, however I'm surely missing a point somwhere.
So if anyone has some suggestions on how to define additional custom views using those frameworks, I'd really appreciate.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我确实错过了一些东西,因为视图声明不足以创建视图。我们必须显式触发视图创建,例如通过将类代码更新为:
OK, I have indeed missed something as the view declaration is not sufficient to create the view. We have to explicitly trigger the view creation, for instance by updating the class code to :