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 always should 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 passes multiple ids.
Supported following options:
-
consistent_read -
range_key -
raise_error
63 64 65 66 67 68 69 |
# File 'lib/dynamoid/finders.rb', line 63 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 |