Class: Mongo::BulkWrite::Result
- Inherits:
-
Object
- Object
- Mongo::BulkWrite::Result
- Defined in:
- lib/mongo/bulk_write/result.rb
Overview
Wraps a series of bulk write operations in a result object.
Constant Summary collapse
- REMOVED_COUNT =
Constant for number removed.
'n_removed'- INSERTED_COUNT =
Constant for number inserted.
'n_inserted'- INSERTED_IDS =
Constant for inserted ids.
'inserted_ids'- MATCHED_COUNT =
Constant for number matched.
'n_matched'- MODIFIED_COUNT =
Constant for number modified.
'n_modified'- UPSERTED =
Constant for upserted.
'upserted'- UPSERTED_COUNT =
Constant for number upserted.
'n_upserted'- UPSERTED_IDS =
Constant for upserted ids.
'upserted_ids'- FIELDS =
The fields contained in the result document returned from executing the operations.
[ INSERTED_COUNT, REMOVED_COUNT, MODIFIED_COUNT, UPSERTED_COUNT, MATCHED_COUNT, Operation::Result::N ].freeze
Instance Attribute Summary collapse
-
#server_addresses ⇒ Array<String>
readonly
Deduplicated list of “host:port” addresses of the servers that produced this bulk write’s operations.
Instance Method Summary collapse
-
#acknowledged? ⇒ Boolean
Is the result acknowledged?.
-
#deleted_count ⇒ Integer
Returns the number of documents deleted.
-
#initialize(results, acknowledged, server_addresses = []) ⇒ Result
constructor
private
Create the new result object from the results document.
-
#inserted_count ⇒ Integer
Returns the number of documents inserted.
-
#inserted_ids ⇒ Array<BSON::ObjectId>
Get the inserted document ids, if the operation has inserts.
-
#matched_count ⇒ Integer
Returns the number of documents matched.
-
#modified_count ⇒ Integer
Returns the number of documents modified.
-
#upserted_count ⇒ Integer
Returns the number of documents upserted.
-
#upserted_ids ⇒ Array<BSON::ObjectId>
Get the upserted document ids, if the operation has inserts.
-
#validate! ⇒ Result
Validates the bulk write result.
Constructor Details
#initialize(results, acknowledged, server_addresses = []) ⇒ 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.
Create the new result object from the results document.
111 112 113 114 115 |
# File 'lib/mongo/bulk_write/result.rb', line 111 def initialize(results, acknowledged, server_addresses = []) @results = results @acknowledged = acknowledged @server_addresses = Array(server_addresses).compact.uniq end |
Instance Attribute Details
#server_addresses ⇒ Array<String> (readonly)
Returns Deduplicated list of “host:port” addresses of the servers that produced this bulk write’s operations.
30 31 32 |
# File 'lib/mongo/bulk_write/result.rb', line 30 def server_addresses @server_addresses end |
Instance Method Details
#acknowledged? ⇒ Boolean
Returns Is the result acknowledged?.
24 25 26 |
# File 'lib/mongo/bulk_write/result.rb', line 24 def acknowledged? @acknowledged end |
#deleted_count ⇒ Integer
Returns the number of documents deleted.
93 94 95 |
# File 'lib/mongo/bulk_write/result.rb', line 93 def deleted_count @results[REMOVED_COUNT] end |
#inserted_count ⇒ Integer
Returns the number of documents inserted.
125 126 127 |
# File 'lib/mongo/bulk_write/result.rb', line 125 def inserted_count @results[INSERTED_COUNT] end |
#inserted_ids ⇒ Array<BSON::ObjectId>
Get the inserted document ids, if the operation has inserts.
137 138 139 |
# File 'lib/mongo/bulk_write/result.rb', line 137 def inserted_ids @results[INSERTED_IDS] end |
#matched_count ⇒ Integer
Returns the number of documents matched.
149 150 151 |
# File 'lib/mongo/bulk_write/result.rb', line 149 def matched_count @results[MATCHED_COUNT] end |
#modified_count ⇒ Integer
Returns the number of documents modified.
161 162 163 |
# File 'lib/mongo/bulk_write/result.rb', line 161 def modified_count @results[MODIFIED_COUNT] end |
#upserted_count ⇒ Integer
Returns the number of documents upserted.
173 174 175 |
# File 'lib/mongo/bulk_write/result.rb', line 173 def upserted_count @results[UPSERTED_COUNT] end |
#upserted_ids ⇒ Array<BSON::ObjectId>
Get the upserted document ids, if the operation has inserts.
185 186 187 |
# File 'lib/mongo/bulk_write/result.rb', line 185 def upserted_ids @results[UPSERTED_IDS] || [] end |
#validate! ⇒ Result
Validates the bulk write result.
199 200 201 202 203 |
# File 'lib/mongo/bulk_write/result.rb', line 199 def validate! raise Error::BulkWriteError.new(@results, server_addresses: @server_addresses) if @results['writeErrors'] || @results['writeConcernErrors'] self end |