Method: Mara::Model::Query::ClassMethods#find

Defined in:
lib/mara/model/query.rb

#find(partition_key, sort_key = nil) ⇒ Mara::Model::Base

Find a single object with the matching partition_key and sort key.

Parameters:

  • partition_key (#to_s)

    The value for the partition key.

  • sort_key (#to_s, nil) (defaults to: nil)

    The value for the sort key.

Returns:

Raises:

  • (NotFoundError)

    If the object doesn’t exist in the table for the requested primary key.

  • (ArgumentError)

    If the partition_key is blank, or the sort_key is blank and the class defines a sort_key name.

Since:

  • 1.0.0



47
48
49
50
51
# File 'lib/mara/model/query.rb', line 47

def find(partition_key, sort_key = nil)
   Mara.instrument('model.find', class_name: name, partition_key: partition_key, sort_key: sort_key) do
    _find(partition_key, sort_key)
  end
end