0

我已经创建了我的模型,正确设置了表格等,数据被保存但是当我尝试搜索我得到错误的东西时

/opt/ruby/lib/ruby/gems/1.8/gems/aws-sdk-1.8.0/lib/aws/record/scope.rb:169:in `send': undefined method `title' for Prop:Class (NoMethodError)

尝试查找条件时:

/opt/ruby/lib/ruby/gems/1.8/gems/aws-sdk-1.8.0/lib/aws/record/scope.rb:169:in `send': undefined method `conditions' for Prop:Class (NoMethodError)

当尝试 Prop.where("title = 'blah')

/opt/ruby/lib/ruby/gems/1.8/gems/aws-sdk-1.8.0/lib/aws/record/scope.rb:169:in `send': undefined method `where' for Prop:Class (NoMethodError)

基本上我的表叫做 Prop,属性是 id、title、date_time 等等。除了 find(id) 或 find_by_id(id) 之外的任何东西都会因该错误而失败。

还有什么我应该做的吗?

谢谢!

4

1 回答 1

1

DynamoDb 键是 Hash 或 Hash-Range 组合。

DynamoDb 只允许您查询键(除非您定义了新的 LSI -本地二级索引)。
即使使用 LSI,您仍然无法对没有范围键属性的表进行复杂查询。

如果您的 Prop 对象只有一个哈希键属性 - id。
您将必须搜索所有表格(称为Scan的操作)并在您的应用程序中过滤您想要的表格

于 2013-04-28T09:18:48.543 回答