Result — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Operation::Aggregate::Result

Inherits:

Result

Defined in:

lib/mongo/operation/aggregate/result.rb

Overview

Defines custom behavior of results in an aggregation context.

Constant Summarycollapse

EXPLAIN =

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

The field name for the aggregation explain information.

'stages'.freeze

EXPLAIN_LEGACY =

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

The legacy field name for the aggregation explain information.

'serverPipeline'.freeze

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

#connection, #connection_description, #connection_global_id, #context, #replies

Instance Method Summarycollapse

Methods inherited from Result

#acknowledged?, #cluster_time, #each, #error, #has_cursor_id?, #initialize, #inspect, #labels, #namespace, #ok?, #operation_time, #reply, #returned_count, #snapshot_timestamp, #successful?, #topology_version, #validate!, #write_concern_error?, #written_count

Instance Method Details

#cursor_id ⇒ Integer

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 aggregation framework and must be retrieved from the cursor document itself. Wahnsinn!

Get the cursor id for the result.

54 55 56 # File 'lib/mongo/operation/aggregate/result.rb', line 54 def cursor_id cursor_document ? cursor_document[CURSOR_ID] : 0 end

#documents ⇒ ArrayBSON::Document

Get the documents for the aggregation result. This is either the first document’s ‘result’ field, or if a cursor option was selected, it is the ‘firstBatch’ field in the ‘cursor’ field of the first document returned. Otherwise, it is an explain document.

| 79 80 81 82 83 84 | # File 'lib/mongo/operation/aggregate/result.rb', line 79 def documents docs = reply.documents[0][RESULT] docs ||= cursor_document[FIRST_BATCH] if cursor_document docs | |= explain_document docs end | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |

#post_batch_resume_token ⇒ BSON::Document | 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.

Get the post batch resume token for the result

63 64 65 # File 'lib/mongo/operation/aggregate/result.rb', line 63 def post_batch_resume_token cursor_document ? cursor_document['postBatchResumeToken'] : nil end