Ruby on rails 使用CouchRest的Couchdb查找器
我只是想知道在使用couchdb的同时如何在Rails中构建find_all_by_action_和author_id方法。我的模型如下所示:Ruby on rails 使用CouchRest的Couchdb查找器,ruby-on-rails,couchdb,couchrest,findby,Ruby On Rails,Couchdb,Couchrest,Findby,我只是想知道在使用couchdb的同时如何在Rails中构建find_all_by_action_和author_id方法。我的模型如下所示: class Activity < CouchRest::Model::Base property :action, String property :author_id, String end 我不知道如何获得正确的结果,我尝试了以下方法: Activity.by_action_and_author_id(:keys => [
class Activity < CouchRest::Model::Base
property :action, String
property :author_id, String
end
我不知道如何获得正确的结果,我尝试了以下方法:
Activity.by_action_and_author_id(:keys => [['action','foo'], ['author_id', '1']]).all
但结果总是一个空哈希。最好的方法是什么?有什么例子吗
使用PostgreSQL时,它看起来是这样的
Activity.where(action: 'foo', author_id: '1').all
不可能这么复杂
Thanx查看一下生成的couchdb视图!您可以看到发出了哪些关键点。这里没有映射,所以我认为
[[['action','foo'],['author\u id','1']]]
应该是['foo','1']
我不确定couchrest模型如何处理视图,但您可以在此处找到更多信息:
请看一下标记示例
Activity.where(action: 'foo', author_id: '1').all