class Mongo::Operation::Find::Result

Defines custom behavior of results in find command.

@since 2.2.0 @api semiprivate

Public Instance Methods

cursor_id() click to toggle source

Get the cursor id.

@example Get the cursor id.

result.cursor_id

@return [ Integer ] The cursor id.

@since 2.2.0 @api private

Calls superclass method Mongo::Operation::Result#cursor_id
# File lib/mongo/operation/find/result.rb, line 34
def cursor_id
  cursor_document ? cursor_document[CURSOR_ID] : super
end
documents() click to toggle source

Get the documents in the result.

@example Get the documents.

result.documents

@return [ Array<BSON::Document> ] The documents.

@since 2.2.0 @api public

# File lib/mongo/operation/find/result.rb, line 47
def documents
  cursor_document[FIRST_BATCH]
end
namespace() click to toggle source

The namespace in which this find command was performed.

@return [ String ] The namespace, usually in the format

"database.collection".

@api private

# File lib/mongo/operation/find/result.rb, line 57
def namespace
  cursor_document['ns']
end

Private Instance Methods

cursor_document() click to toggle source
# File lib/mongo/operation/find/result.rb, line 63
def cursor_document
  @cursor_document ||= reply.documents[0][CURSOR]
end
first_document() click to toggle source
# File lib/mongo/operation/find/result.rb, line 67
def first_document
  @first_document ||= reply.documents[0]
end