MongoD...Result(3pm)
π MongoDB::BulkWriteResult β the receipts for your bulk write π
okay bestie, welcome to MongoDB::BulkWriteResult, aka the little document that tells you what actually went down after a bulk write. it's a Perl thing, from the User Contributed Perl Documentation manual (the manpage name is MongoD...Result(3pm) if you're keeping score β¨).
β¨ VERSION β¨
version v2.2.2 β that's the one, no cap.
πΈ SYNOPSIS πΈ
so here's how you get one of these bad boys:
# returned directly
my $result = $bulk->execute;
# from a WriteError or WriteConcernError
my $result = $error->result;
if ( $result->acknowledged ) {
...
}
like, either it comes straight back from execute, or you fish it out of an error. both cute. π
π¦ DESCRIPTION π¦
This class is the whole vibe of "what happened during my bulk write." It can come back to you directly from execute, or it can be chilling in the result attribute of a MongoDB::DatabaseError subclass β think MongoDB::WriteError or MongoDB::WriteConcernError. the way that errors just bring receipts with them, honestly obsessed. π
π ATTRIBUTES π
π inserted_count
Number of documents inserted. periodt.
π upserted_count
Number of documents upserted. (upsert girlies rise π«Ά)
π matched_count
Number of documents matched for an update or replace operation.
π deleted_count
Number of documents removed. gone, bye, no notes. π
π modified_count
Number of documents actually modified by an update operation. and lowkey this is not necessarily the same as matched_count β if the document was not actually modified as a result of the update, the numbers can differ, fr fr.
β οΈ this field is not available from legacy servers before version 2.6. If results are seen from a legacy server (or from a mongos proxying for a legacy server), this attribute will be undef.
and you can call has_modified_count to find out if this attribute is defined or not. handy bestie behaviour. β¨
π upserted
An array reference containing information about upserted documents (if any). Each document will have the following fields:
indexβ 0-based index indicating which operation failed_idβ the object ID of the upserted document
π upserted_ids
A hash reference built lazily from upserted, mapping indexes to object IDs. lazy but make it useful π
π inserted
An array reference containing information about inserted documents (if any). Documents are just as in upserted.
π inserted_ids
A hash reference built lazily from inserted, mapping indexes to object IDs.
π write_errors
An array reference containing write errors (if any). Each error document will have the following fields:
indexβ 0-based index indicating which operation failedcodeβ numeric error codeerrmsgβ textual error stringopβ a representation of the actual operation sent to the server
π write_concern_errors
An array reference containing write concern errors (if any). Each error document will have the following fields:
indexβ 0-based index indicating which operation failedcodeβ numeric error code
π op_count
The number of operations sent to the database. counting the vibes. π₯
π batch_count
The number of database commands issued to the server. This will be less than the op_count if multiple operations were grouped together β grouping is the main character energy here. π
π METHODS π
π assert
Throws an error if write errors or write concern errors occurred. it's giving "we need to talk."
π assert_no_write_error
Throws a MongoDB::WriteError if count_write_errors is non-zero; otherwise returns 1. slay.
π assert_no_write_concern_error
Throws a MongoDB::WriteConcernError if count_write_concern_errors is non-zero; otherwise returns 1.
π count_write_errors
Returns the number of write errors. simple. iconic. π
π count_write_concern_errors
Returns the number of write errors.
π last_code
Returns the last code field from either the list of write_errors or write_concern_errors, or 0 if there are no errors.
π last_errmsg
Returns the last errmsg field from either the list of write_errors or write_concern_errors, or the empty string if there are no errors.
π last_wtimeout
True if a write concern timed out, or false otherwise. π (hopefully false)
π AUTHORS π
the legends behind this, in no particular order but here's the list:
- David Golden
<david@mongodb.com> - Rassi
<rassi@mongodb.com> - Mike Friedman
<friedo@friedo.com> - Kristina Chodorow
<k.chodorow@gmail.com> - Florian Ragwitz
<rafl@debian.org>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2020 by MongoDB, Inc.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
and that's the whole page bestie, perl v5.40.1, dated 2025-04-03 π«Ά go forth and check your acknowledged before you do anything else, iykyk β¨π
π¦
π¦ where this page comes from
- debian trixie: libmongodb-perl 2.2.2-3 Β· Apache-2.0
- ubuntu resolute: libmongodb-perl 2.2.2-3 Β· Apache-2.0
- ubuntu stonking: libmongodb-perl 2.2.2-3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms