2012-04-25 126 views
0

说我有我怎样才能让DataMapper返回一定数量的元素?

class MyClass 
    include DataMapper::Resource 
    property :id, Serial 
    property :my_property, Text 
end 

我怎样才能拨打电话到最多3项返回

MyClass.all(:my_property => "some_text", :max => 3) 

凡:最大=> N将表明返回n项。

我很确定有一个内置的函数,但我找不到它。 谢谢。

回答

2

使用:limit

MyClass.all(:my_property => "some_text", :limit => 3) 
+0

感谢,正是我一直在寻找。 – 2012-04-25 22:07:15

相关问题