Class: Mongo::BulkWrite::Result
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/mongo/bulk_write/result.rb |
Overview
Wraps a series of bulk write operations in a result object.
Constant Summary
-
FIELDS =
# File 'lib/mongo/bulk_write/result.rb', line 72
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
-
INSERTED_COUNT =
# File 'lib/mongo/bulk_write/result.rb', line 36
Constant for number inserted.
'n_inserted' -
INSERTED_IDS =
# File 'lib/mongo/bulk_write/result.rb', line 41
Constant for inserted ids.
'inserted_ids' -
MATCHED_COUNT =
# File 'lib/mongo/bulk_write/result.rb', line 46
Constant for number matched.
'n_matched' -
MODIFIED_COUNT =
# File 'lib/mongo/bulk_write/result.rb', line 51
Constant for number modified.
'n_modified' -
REMOVED_COUNT =
# File 'lib/mongo/bulk_write/result.rb', line 31
Constant for number removed.
'n_removed' -
UPSERTED =
# File 'lib/mongo/bulk_write/result.rb', line 56
Constant for upserted.
'upserted' -
UPSERTED_COUNT =
# File 'lib/mongo/bulk_write/result.rb', line 61
Constant for number upserted.
'n_upserted' -
UPSERTED_IDS =
# File 'lib/mongo/bulk_write/result.rb', line 66
Constant for upserted ids.
'upserted_ids'
Class Method Summary
-
.new(results, acknowledged) ⇒ Result
constructor
Internal use only
Internal use only
Create the new result object from the results document.
Instance Attribute Summary
- #acknowledged? ⇒ Boolean readonly
Instance Method Summary
-
#deleted_count ⇒ Integer
Returns the number of documents deleted.
-
#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.
Instance Attribute Details
#acknowledged? ⇒ Boolean (readonly)
# File 'lib/mongo/bulk_write/result.rb', line 24
def acknowledged? @acknowledged end
Instance Method Details
#deleted_count ⇒ Integer
Returns the number of documents deleted.
# File 'lib/mongo/bulk_write/result.rb', line 89
def deleted_count @results[REMOVED_COUNT] end
#inserted_count ⇒ Integer
Returns the number of documents inserted.
# File 'lib/mongo/bulk_write/result.rb', line 117
def inserted_count @results[INSERTED_COUNT] end
#inserted_ids ⇒ Array<BSON::ObjectId>
Get the inserted document ids, if the operation has inserts.
# File 'lib/mongo/bulk_write/result.rb', line 129
def inserted_ids @results[INSERTED_IDS] end
#matched_count ⇒ Integer
Returns the number of documents matched.
# File 'lib/mongo/bulk_write/result.rb', line 141
def matched_count @results[MATCHED_COUNT] end
#modified_count ⇒ Integer
Returns the number of documents modified.
# File 'lib/mongo/bulk_write/result.rb', line 153
def modified_count @results[MODIFIED_COUNT] end
#upserted_count ⇒ Integer
Returns the number of documents upserted.
# File 'lib/mongo/bulk_write/result.rb', line 165
def upserted_count @results[UPSERTED_COUNT] end
#upserted_ids ⇒ Array<BSON::ObjectId>
Get the upserted document ids, if the operation has inserts.
# File 'lib/mongo/bulk_write/result.rb', line 177
def upserted_ids @results[UPSERTED_IDS] || [] end
#validate! ⇒ Result
Validates the bulk write result.
# File 'lib/mongo/bulk_write/result.rb', line 191
def validate! raise Error::BulkWriteError.new(@results) if @results['writeErrors'] || @results['writeConcernErrors'] self end