Class: Mongo::BulkWrite::Result
- Inherits:
-
Object
- Object
- Mongo::BulkWrite::Result
- Defined in:
- build/ruby-driver-v2.17/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'.freeze
- INSERTED_COUNT =
Constant for number inserted.
'n_inserted'.freeze
- INSERTED_IDS =
Constant for inserted ids.
'inserted_ids'.freeze
- MATCHED_COUNT =
Constant for number matched.
'n_matched'.freeze
- MODIFIED_COUNT =
Constant for number modified.
'n_modified'.freeze
- UPSERTED =
Constant for upserted.
'upserted'.freeze
- UPSERTED_COUNT =
Constant for number upserted.
'n_upserted'.freeze
- UPSERTED_IDS =
Constant for upserted ids.
'upserted_ids'.freeze
- 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 Method Summary collapse
-
#deleted_count ⇒ Integer
Returns the number of documents deleted.
-
#initialize(results) ⇒ Result
constructor
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) ⇒ Result
Create the new result object from the results document.
99 100 101 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 99 def initialize(results) @results = results end |
Instance Method Details
#deleted_count ⇒ Integer
Returns the number of documents deleted.
87 88 89 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 87 def deleted_count @results[REMOVED_COUNT] end |
#inserted_count ⇒ Integer
Returns the number of documents inserted.
111 112 113 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 111 def inserted_count @results[INSERTED_COUNT] end |
#inserted_ids ⇒ Array<BSON::ObjectId>
Get the inserted document ids, if the operation has inserts.
123 124 125 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 123 def inserted_ids @results[INSERTED_IDS] end |
#matched_count ⇒ Integer
Returns the number of documents matched.
135 136 137 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 135 def matched_count @results[MATCHED_COUNT] end |
#modified_count ⇒ Integer
Returns the number of documents modified.
147 148 149 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 147 def modified_count @results[MODIFIED_COUNT] end |
#upserted_count ⇒ Integer
Returns the number of documents upserted.
159 160 161 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 159 def upserted_count @results[UPSERTED_COUNT] end |
#upserted_ids ⇒ Array<BSON::ObjectId>
Get the upserted document ids, if the operation has inserts.
171 172 173 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 171 def upserted_ids @results[UPSERTED_IDS] || [] end |
#validate! ⇒ Result
Validates the bulk write result.
185 186 187 188 189 190 191 |
# File 'build/ruby-driver-v2.17/lib/mongo/bulk_write/result.rb', line 185 def validate! if @results['writeErrors'] || @results['writeConcernErrors'] raise Error::BulkWriteError.new(@results) else self end end |