Class: Cuprum::Collections::Basic::Commands::FindMany

Inherits:
Cuprum::Collections::Basic::Command show all
Includes:
Commands::AbstractFindMany
Defined in:
lib/cuprum/collections/basic/commands/find_many.rb

Overview

Command for finding multiple collection items by primary key.

Instance Attribute Summary

Attributes inherited from Cuprum::Collections::Basic::Command

#collection_name, #data, #default_contract, #member_name, #options, #primary_key_name, #primary_key_type

Instance Method Summary collapse

Methods inherited from Cuprum::Collections::Basic::Command

#initialize, subclass

Constructor Details

This class inherits a constructor from Cuprum::Collections::Basic::Command

Instance Method Details

#call(primary_keys: , allow_partial: false, envelope: false, scope: nil) ⇒ Cuprum::Result<Array<Hash{String, Object}>>

Queries the collection for the items with the given primary keys.

The command will find and return the entities with the given primary keys. If any of the items are not found, the command will fail and return a NotFound error. If the :allow_partial option is set, the command will return a partial result unless none of the requested items are found.

When the :envelope option is true, the command wraps the items in a Hash, using the name of the collection as the key.

Parameters:

  • allow_partial (Boolean) (defaults to: false)

    If true, passes if any of the items are found.

  • envelope (Boolean) (defaults to: false)

    If true, wraps the result value in a Hash.

  • primary_keys (Array) (defaults to: )

    The primary keys of the requested items.

  • scope (Cuprum::Collections::Basic::Query, nil) (defaults to: nil)

    Optional scope for the query. Items must match the scope as well as the primary keys.

Returns:

  • (Cuprum::Result<Array<Hash{String, Object}>>)

    a result with the requested items.



35
36
37
38
39
40
# File 'lib/cuprum/collections/basic/commands/find_many.rb', line 35

validate_parameters :call do
  keyword :allow_partial, Stannum::Constraints::Boolean.new, default: true
  keyword :envelope,      Stannum::Constraints::Boolean.new, default: true
  keyword :primary_keys,  Array
  keyword :scope,         Cuprum::Collections::Basic::Query, optional: true
end