Class: Mongo::Operation::CursorCommand::Result Private

Inherits:
Operation::Result
  • Object
show all
Defined in:
lib/mongo/operation/cursor_command/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.

Parses the cursor field of a command response so a Cursor can be built from the result. The parsing is identical to a find command result.

Instance Method Summary collapse

Instance Method Details

#cursor?true | false

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.

Returns Whether the command response contained a cursor field.

Returns:

  • (true | false)

    Whether the command response contained a cursor field.



27
28
29
# File 'lib/mongo/operation/cursor_command/result.rb', line 27

def cursor?
  !cursor_document.nil?
end

#cursor_idInteger | nil

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.

Returns The cursor id from the cursor document.

Returns:

  • (Integer | nil)

    The cursor id from the cursor document.



32
33
34
# File 'lib/mongo/operation/cursor_command/result.rb', line 32

def cursor_id
  cursor? ? 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.

Returns The first batch of documents.

Returns:

  • (Array<BSON::Document>)

    The first batch of documents.



37
38
39
# File 'lib/mongo/operation/cursor_command/result.rb', line 37

def documents
  cursor? ? cursor_document[FIRST_BATCH] : []
end

#namespaceString | nil

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.

Returns The cursor namespace, "database.collection".

Returns:

  • (String | nil)

    The cursor namespace, "database.collection".



42
43
44
# File 'lib/mongo/operation/cursor_command/result.rb', line 42

def namespace
  cursor? ? cursor_document['ns'] : super
end