MongoD...Result(3pm)

πŸ“¦
version 2.2.2 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 failed
  • code β€” numeric error code
  • errmsg β€” textual error string
  • op β€” 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 failed
  • code β€” 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>

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