NAME
MongoDB::BulkWriteView - Bulk write operations against a query document
VERSION
version v0.999.998.3
SYNOPSIS
my $bulk = $collection->initialize_ordered_bulk_op;
# Update one document matching the selector
bulk->find( { a => 1 } )->update_one( { '$inc' => { x => 1 } } );
# Update all documents matching the selector
bulk->find( { a => 2 } )->update( { '$inc' => { x => 2 } } );
# Update all documents
bulk->find( {} )->update( { '$inc' => { x => 2 } } );
# Replace entire document (update with whole doc replace)
bulk->find( { a => 3 } )->replace_one( { x => 3 } );
# Update one document matching the selector or upsert
bulk->find( { a => 1 } )->upsert()->update_one( { '$inc' => { x => 1 } } );
# Update all documents matching the selector or upsert
bulk->find( { a => 2 } )->upsert()->update( { '$inc' => { x => 2 } } );
# Replaces a single document matching the selector or upsert
bulk->find( { a => 3 } )->upsert()->replace_one( { x => 3 } );
# Remove a single document matching the selector
bulk->find( { a => 4 } )->remove_one();
# Remove all documents matching the selector
bulk->find( { a => 5 } )->remove();
# Remove all documents
bulk->find( {} )->remove();
DESCRIPTION
This class provides means to specify write operations constrained by a query document.
To instantiate a MongoDB::BulkWriteView
, use the find method from MongoDB::BulkWrite or the "upsert" method described below.
Except for "upsert", all methods have an empty return on success; an exception will be thrown on error.
METHODS
remove
$bulk->remove;
Removes all documents matching the query document.
remove_one
$bulk->remove_one;
Removes a single document matching the query document.
replace_one
$bulk->replace_one( $doc );
Replaces the document matching the query document. The document to replace must not have any keys that begin with a dollar sign, $
.
update
$bulk->update( $modification );
Updates all documents matching the query document. The modification document must have all its keys begin with a dollar sign, $
.
update_one
$bulk->update_one( $modification );
Updates a single document matching the query document. The modification document must have all its keys begin with a dollar sign, $
.
upsert
$bulk->upsert->replace_one( $doc );
Returns a new MongoDB::BulkWriteView
object that will treat every update, update_one or replace_one operation as an upsert operation.
AUTHORS
David Golden <david@mongodb.com>
Mike Friedman <friedo@mongodb.com>
Kristina Chodorow <kristina@mongodb.com>
Florian Ragwitz <rafl@debian.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2015 by MongoDB, Inc..
This is free software, licensed under:
The Apache License, Version 2.0, January 2004