2012-04-25 77 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