Method: Dynamoid::Finders::ClassMethods#find
- Defined in:
- lib/dynamoid/finders.rb
#find(*ids, **options) ⇒ Dynamoid::Document
Find one or many objects, specified by one id or an array of ids.
By default it raises RecordNotFound exception if at least one model isn’t found. This behavior can be changed with raise_error option. If specified raise_error: false option then find will not raise the exception.
When a document schema includes range key it should always be specified in find method call. In case it’s missing MissingRangeKey exception will be raised.
Please note that find doesn’t preserve order of models in result when given multiple ids.
Supported following options:
-
consistent_read -
range_key -
raise_error
52 53 54 55 56 57 58 |
# File 'lib/dynamoid/finders.rb', line 52 def find(*ids, **) if ids.size == 1 && !ids[0].is_a?(Array) _find_by_id(ids[0], .reverse_merge(raise_error: true)) else _find_all(ids.flatten(1), .reverse_merge(raise_error: true)) end end |