module AWS::Record::FinderMethods
def [] id
-
(Record::Base)
- Returns the record, as a sub-class of
Raises:
-
(RecordNotFound)
- Raises a record not found exception if there
Parameters:
-
id
(String
) -- The id of the record to load.
def [] id data = sdb_domain.items[id].data.attributes raise RecordNotFound, "no data found for id: #{id}" if data.empty? obj = self.new obj.send(:hydrate, id, data) obj end
def all options = {}
-
(Scope)
- Returns an enumerable scope object.
def all options = {} find(:all, options) end
def count(options = {})
(**options)
-
:limit
(Integer
) -- The max number of records to count. -
:where
(Mixed
) -- Conditions that determine what
Parameters:
-
options
(Hash
) -- ({}
) Options for counting
def count(options = {}) find(:all).count(options) end
def find *args
(**options)
-
:limit
(Integer
) -- The max number of records to fetch. -
:sort
(String, Array
) -- The order records should be -
:where
(Mixed
) -- Conditions that determine what
Parameters:
-
options
(Hash
) -- -
mode
(:all, :first
) -- (:all) When finding +:all+ matching records -
id
() -- The record to find, raises an exception if the record is
Overloads:
-
find(mode, options = {})
-
find(id)
def find *args _new_scope.find(*args) end
def first options = {}
-
(Object, nil)
- Returns the first record found for the current
def first options = {} _new_scope.find(:first, options) end
def limit limit
People.where(:age => 40).limit(10).each {|person| ... }
Limit can be chained with other scope modifiers:
People.limit(10).each {|person| ... }
matching the where conditions will be returned from a find.
The maximum number of records to return. By default, all records
def limit limit _new_scope.limit(limit) end
def order *args
-
direction
(:asc, :desc
) -- (:asc) The direction to sort, ascending -
attribute
(String, Symbol
) -- The attribute in SimpleDB to sort by.
Overloads:
-
order(attribute, direction = :asc)
def order *args _new_scope.order(*args) end
def where *args
-
conditions_hash
(Hash
) -- A hash of attributes to values. Each
Overloads:
-
where(sql_fragment[, quote_params, ...])
-
where(conditions_hash)
def where *args _new_scope.where(*args) end