Class: Mongo::Operation::Indexes::Result Private

Inherits:
Result
  • Object
show all
Defined in:
lib/mongo/operation/indexes/result.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defines custom behaviour of results when using the listIndexes command.

Since:

  • 2.0.0

Constant Summary

Constants inherited from Result

Result::CURSOR, Result::CURSOR_ID, Result::FIRST_BATCH, Result::N, Result::NAMESPACE, Result::NEXT_BATCH, Result::OK, Result::RESULT

Instance Attribute Summary

Attributes inherited from Result

#replies

Instance Method Summary collapse

Methods inherited from Result

#acknowledged?, #cluster_time, #each, #initialize, #inspect, #multiple?, #ok?, #operation_time, #reply, #returned_count, #successful?, #written_count

Constructor Details

This class inherits a constructor from Mongo::Operation::Result

Instance Method Details

#cursor_idInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Even though the wire protocol has a cursor_id field for all messages of type reply, it is always zero when using the listIndexes command and must be retrieved from the cursor document itself.

Get the cursor id for the result.

Examples:

Get the cursor id.

result.cursor_id

Returns:

  • (Integer)

    The cursor id.

Since:

  • 2.0.0



38
39
40
# File 'lib/mongo/operation/indexes/result.rb', line 38

def cursor_id
  cursor_document ? cursor_document[CURSOR_ID] : super
end

#documentsArray<BSON::Document>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the documents for the listIndexes result. This is the 'firstBatch' field in the 'cursor' field of the first document returned.

Examples:

Get the documents.

result.documents

Returns:

  • (Array<BSON::Document>)

    The documents.

Since:

  • 2.0.0



63
64
65
# File 'lib/mongo/operation/indexes/result.rb', line 63

def documents
  cursor_document[FIRST_BATCH]
end

#namespaceString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the namespace for the cursor.

Examples:

Get the namespace.

result.namespace

Returns:

  • (String)

    The namespace.

Since:

  • 2.0.0



50
51
52
# File 'lib/mongo/operation/indexes/result.rb', line 50

def namespace
  cursor_document ? cursor_document[NAMESPACE] : super
end

#validate!Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validate the result. In the case where the database or collection does not exist on the server we will get an error, and it's better to raise a meaningful exception here than the ambiguous one when the error occurs.

Examples:

Validate the result.

result.validate!

Returns:

  • (Result)

    Self if successful.

Raises:

  • (NoNamespace)

    If the ns doesn't exist.

Since:

  • 2.0.0



80
81
82
# File 'lib/mongo/operation/indexes/result.rb', line 80

def validate!
  !successful? ? raise_operation_failure : self
end