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

Class: Mongo::Operation::Insert::Result

Inherits:

Result

Defined in:

lib/mongo/operation/insert/result.rb

Overview

Defines custom behavior of results for an insert.

According to the CRUD spec, reporting the inserted ids is optional. It can be added to this class later, if needed.

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 collapse

Attributes inherited from Result

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

Instance Method Summarycollapse

Methods inherited from Result

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

Constructor Details

#initialize(replies, connection_description, connection_global_id, ids, context: nil) ⇒ 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.

Initialize a new result.

55 56 57 58 # File 'lib/mongo/operation/insert/result.rb', line 55 def initialize(, connection_description, connection_global_id, ids, context: nil) super(, connection_description, connection_global_id, context: context) @inserted_ids = ids end

Instance Attribute Details

#inserted_ids ⇒ Object

Get the ids of the inserted documents.

35 36 37 # File 'lib/mongo/operation/insert/result.rb', line 35 def inserted_ids @inserted_ids end

Instance Method Details

#bulk_result ⇒ Object

74 75 76 # File 'lib/mongo/operation/insert/result.rb', line 74 def bulk_result BulkResult.new(@replies, connection_description, connection_global_id, @inserted_ids) end

#inserted_id ⇒ Object

Gets the id of the document inserted.

69 70 71 # File 'lib/mongo/operation/insert/result.rb', line 69 def inserted_id inserted_ids.first end