MongoDB::BulkWrite(3pm) - phpMan

Command: man perldoc info search(apropos)  


MongoDB::BulkWrite(3pm)        User Contributed Perl Documentation        MongoDB::BulkWrite(3pm)

NAME
       MongoDB::BulkWrite - MongoDB bulk write interface

VERSION
       version v2.2.0

SYNOPSIS
           use Safe::Isa;
           use Try::Tiny;

           my $bulk = $collection->initialize_ordered_bulk_op;

           $bulk->insert_one( $doc );
           $bulk->find( $query )->upsert->replace_one( $doc )
           $bulk->find( $query )->update( $modification )

           my $result = try {
               $bulk->execute;
           }
           catch {
               if ( $_->$isa("MongoDB::WriteConcernError") ) {
                   warn "Write concern failed";
               }
               else {
                   die $_;
               }
           };

DESCRIPTION
       This class constructs a list of write operations to perform in bulk for a single
       collection.  On a MongoDB 2.6 or later server with write command support this allow
       grouping similar operations together for transit to the database, minimizing network
       round-trips.

       To begin a bulk operation, use one these methods from MongoDB::Collection:

       o   initialize_ordered_bulk_op

       o   initialize_unordered_bulk_op

   Ordered Operations
       With an ordered operations list, MongoDB executes the write operations in the list
       serially. If an error occurs during the processing of one of the write operations, MongoDB
       will return without processing any remaining write operations in the list.

   Unordered Operations
       With an unordered operations list, MongoDB can execute in parallel, as well as in a
       nondeterministic order, the write operations in the list. If an error occurs during the
       processing of one of the write operations, MongoDB will continue to process remaining
       write operations in the list.

ATTRIBUTES
   collection (required)
       The MongoDB::Collection where the operations are to be performed.

   ordered (required)
       A boolean for whether or not operations should be ordered (true) or unordered (false).

   bypassDocumentValidation
       A boolean for whether or not operations should bypass document validation.  Default is
       false.

METHODS
   find
           $view = $bulk->find( $query_document );

       The "find" method returns a MongoDB::BulkWriteView object that allows write operations
       like "update" or "remove", constrained by a query document.

       A query document is required.  Use an empty hashref for no criteria:

           $bulk->find( {} )->remove; # remove all documents!

       An exception will be thrown on error.

   insert_one
           $bulk->insert_one( $doc );

       Queues a document for insertion when "execute" is called.  The document may be a hash
       reference, an array reference (with balanced key/value pairs) or a Tie::IxHash object.  If
       the document does not have an "_id" field, one will be added to the original.

       The method has an empty return on success; an exception will be thrown on error.

   execute
           my $result = $bulk->execute;
           # Optional write concern:
           my $result = $bulk->execute( $concern );
           # With options
           my $result = $bulk->execute( $concern, $options );

       Executes the queued operations.  The order and semantics depend on whether the bulk object
       is ordered or unordered:

       o   ordered -- operations are executed in order, but operations of the same type (e.g.
           multiple inserts) may be grouped together and sent to the server.  If the server
           returns an error, the bulk operation will stop and an error will be thrown.

       o   unordered -- operations are grouped by type and sent to the server in an unpredictable
           order.  After all operations are sent, if any errors occurred, an error will be
           thrown.

       When grouping operations of a type, operations will be sent to the server in batches not
       exceeding 16MiB or 1000 items (for a version 2.6 or later server) or individually (for
       legacy servers without write command support).

       A write concern is optional, and can either take a pre-constructed WriteConcern object, or
       the arguments to construct one.  For information on write concerns, see
       MongoDB::WriteConcern.

       The options argument is an optional hashref which can contain the following values:

       o   "session" - the session to use for these operations. If not supplied, will use an
           implicit session. For more information see MongoDB::ClientSession

       This method returns a MongoDB::BulkWriteResult object if the bulk operation executes
       successfully.

       Typical errors might include:

       o   "MongoDB::WriteError" -- one or more write operations failed

       o   "MongoDB::WriteConcernError" - all writes were accepted by a primary, but the write
           concern failed

       o   "MongoDB::DatabaseError" -- a command to the database failed entirely

       See MongoDB::Error for more on error handling.

       NOTE: it is an error to call "execute" without any operations or to call "execute" more
       than once on the same bulk object.

AUTHORS
       o   David Golden <david AT mongodb.com>

       o   Rassi <rassi AT mongodb.com>

       o   Mike Friedman <friedo AT friedo.com>

       o   Kristina Chodorow <k.chodorow AT gmail.com>

       o   Florian Ragwitz <rafl AT debian.org>

COPYRIGHT AND LICENSE
       This software is Copyright (c) 2019 by MongoDB, Inc.

       This is free software, licensed under:

         The Apache License, Version 2.0, January 2004

perl v5.30.0                                2019-10-10                    MongoDB::BulkWrite(3pm)

Generated by $Id: phpMan.php,v 4.55 2007/09/05 04:42:51 chedong Exp $ Author: Che Dong
On Apache
Under GNU General Public License
2024-04-20 03:50 @3.145.105.105 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0!Valid CSS!