%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/opti/optisoftcom-new/perl/usr/man/man3/
Upload File :
Create Path :
Current File : /home/opti/optisoftcom-new/perl/usr/man/man3/MongoDB::Database.3pm

.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "MongoDB::Database 3"
.TH MongoDB::Database 3 "2018-11-30" "perl v5.16.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
MongoDB::Database \- A MongoDB Database
.SH "VERSION"
.IX Header "VERSION"
version v2.0.2
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\&    # get a Database object via MongoDB::MongoClient
\&    my $db   = $client\->get_database("foo");
\&
\&    # get a Collection via the Database object
\&    my $coll = $db\->get_collection("people");
\&
\&    # run a command on a database
\&    my $res = $db\->run_command([ismaster => 1]);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This class models a MongoDB database.  Use it to construct
MongoDB::Collection objects. It also provides the \*(L"run_command\*(R" method and
some convenience methods that use it.
.PP
Generally, you never construct one of these directly with \f(CW\*(C`new\*(C'\fR.  Instead, you
call \f(CW\*(C`get_database\*(C'\fR on a MongoDB::MongoClient object.
.SH "USAGE"
.IX Header "USAGE"
.SS "Error handling"
.IX Subsection "Error handling"
Unless otherwise explicitly documented, all methods throw exceptions if
an error occurs.  The error types are documented in MongoDB::Error.
.PP
To catch and handle errors, the Try::Tiny and Safe::Isa modules
are recommended:
.PP
.Vb 2
\&    use Try::Tiny;
\&    use Safe::Isa; # provides $_isa
\&
\&    try {
\&        $db\->run_command( @command )
\&    }
\&    catch {
\&        if ( $_\->$_isa("MongoDB::DuplicateKeyError" ) {
\&            ...
\&        }
\&        else {
\&            ...
\&        }
\&    };
.Ve
.PP
To retry failures automatically, consider using Try::Tiny::Retry.
.SH "ATTRIBUTES"
.IX Header "ATTRIBUTES"
.SS "name"
.IX Subsection "name"
The name of the database.
.SS "read_preference"
.IX Subsection "read_preference"
A MongoDB::ReadPreference object.  It may be initialized with a string
corresponding to one of the valid read preference modes or a hash reference
that will be coerced into a new MongoDB::ReadPreference object.
By default it will be inherited from a MongoDB::MongoClient object.
.SS "write_concern"
.IX Subsection "write_concern"
A MongoDB::WriteConcern object.  It may be initialized with a hash
reference that will be coerced into a new MongoDB::WriteConcern object.
By default it will be inherited from a MongoDB::MongoClient object.
.SS "read_concern"
.IX Subsection "read_concern"
A MongoDB::ReadConcern object.  May be initialized with a hash
reference or a string that will be coerced into the level of read
concern.
.PP
By default it will be inherited from a MongoDB::MongoClient object.
.SS "max_time_ms"
.IX Subsection "max_time_ms"
Specifies the maximum amount of time in milliseconds that the server should use
for working on a query.
.PP
\&\fBNote\fR: this will only be used for server versions 2.6 or greater, as that
was when the \f(CW$maxTimeMS\fR meta-operator was introduced.
.SS "bson_codec"
.IX Subsection "bson_codec"
An object that provides the \f(CW\*(C`encode_one\*(C'\fR and \f(CW\*(C`decode_one\*(C'\fR methods, such as
from \s-1BSON\s0.  It may be initialized with a hash reference that will
be coerced into a new \s-1BSON\s0 object.  By default it will be inherited
from a MongoDB::MongoClient object.
.SH "METHODS"
.IX Header "METHODS"
.SS "client"
.IX Subsection "client"
.Vb 1
\&    $client = $db\->client;
.Ve
.PP
Returns the MongoDB::MongoClient object associated with this
object.
.SS "list_collections"
.IX Subsection "list_collections"
.Vb 2
\&    $result = $coll\->list_collections( $filter );
\&    $result = $coll\->list_collections( $filter, $options );
.Ve
.PP
Returns a MongoDB::QueryResult object to iterate over collection description
documents.  These will contain \f(CW\*(C`name\*(C'\fR and \f(CW\*(C`options\*(C'\fR keys like so:
.PP
.Vb 1
\&    use boolean;
\&
\&    {
\&        name => "my_capped_collection",
\&        options => {
\&            capped => true,
\&            size => 10485760,
\&        }
\&    },
.Ve
.PP
An optional filter document may be provided, which cause only collection
description documents matching a filter expression to be returned.  See the
listCollections command
documentation <http://docs.mongodb.org/manual/reference/command/listCollections/>
for more details on filtering for specific collections.
.PP
A hash reference of options may be provided. Valid keys include:
.IP "\(bu" 4
\&\f(CW\*(C`batchSize\*(C'\fR X the number of documents to return per batch.
.IP "\(bu" 4
\&\f(CW\*(C`maxTimeMS\*(C'\fR X the maximum amount of time in milliseconds to allow the command to run.  (Note, this will be ignored for servers before version 2.6.)
.IP "\(bu" 4
\&\f(CW\*(C`nameOnly\*(C'\fR \- query and return names of the collections only. Defaults to false. (Note, this will be ignored for servers before version 4.0)
.IP "\(bu" 4
\&\f(CW\*(C`session\*(C'\fR \- the session to use for these operations. If not supplied, will use an implicit session. For more information see MongoDB::ClientSession
.PP
\&\fB\s-1NOTE\s0\fR: When using \f(CW\*(C`nameOnly\*(C'\fR, the filter query must be empty or must only
query the \f(CW\*(C`name\*(C'\fR field or else no documents will be found.
.SS "collection_names"
.IX Subsection "collection_names"
.Vb 3
\&    my @collections = $database\->collection_names;
\&    my @collections = $database\->collection_names( $filter );
\&    my @collections = $database\->collection_names( $filter, $options );
.Ve
.PP
Returns the list of collections in this database.
.PP
An optional filter document may be provided, which cause only collection
description documents matching a filter expression to be returned.  See the
listCollections command
documentation <http://docs.mongodb.org/manual/reference/command/listCollections/>
for more details on filtering for specific collections.
.PP
A hashref of options may also be provided.
.PP
Valid options include:
.IP "\(bu" 4
\&\f(CW\*(C`session\*(C'\fR \- the session to use for these operations. If not supplied, will use an implicit session. For more information see MongoDB::ClientSession
.PP
\&\fBWarning:\fR if the number of collections is very large, this may return
a very large result.  Either pass an appropriate filter, or use
\&\*(L"list_collections\*(R" to iterate over collections instead.
.SS "get_collection, coll"
.IX Subsection "get_collection, coll"
.Vb 3
\&    my $collection = $database\->get_collection(\*(Aqfoo\*(Aq);
\&    my $collection = $database\->get_collection(\*(Aqfoo\*(Aq, $options);
\&    my $collection = $database\->coll(\*(Aqfoo\*(Aq, $options);
.Ve
.PP
Returns a MongoDB::Collection for the given collection name within this
database.
.PP
It takes an optional hash reference of options that are passed to the
MongoDB::Collection constructor.
.PP
The \f(CW\*(C`coll\*(C'\fR method is an alias for \f(CW\*(C`get_collection\*(C'\fR.
.SS "get_gridfsbucket, gfs"
.IX Subsection "get_gridfsbucket, gfs"
.Vb 3
\&    my $grid = $database\->get_gridfsbucket;
\&    my $grid = $database\->get_gridfsbucket($options);
\&    my $grid = $database\->gfs($options);
.Ve
.PP
This method returns a MongoDB::GridFSBucket object for storing and
retrieving files from the database.
.PP
It takes an optional hash reference of options that are passed to the
MongoDB::GridFSBucket constructor.
.PP
See MongoDB::GridFSBucket for more information.
.PP
The \f(CW\*(C`gfs\*(C'\fR method is an alias for \f(CW\*(C`get_gridfsbucket\*(C'\fR.
.SS "drop"
.IX Subsection "drop"
.Vb 1
\&    $database\->drop;
.Ve
.PP
Deletes the database.
.PP
A hashref of options may also be provided.
.PP
Valid options include:
.IP "\(bu" 4
\&\f(CW\*(C`session\*(C'\fR \- the session to use for these operations. If not supplied, will use an implicit session. For more information see MongoDB::ClientSession
.SS "run_command"
.IX Subsection "run_command"
.Vb 1
\&    my $output = $database\->run_command([ some_command => 1 ]);
\&
\&    my $output = $database\->run_command(
\&        [ some_command => 1 ],
\&        { mode => \*(AqsecondaryPreferred\*(Aq }
\&    );
\&
\&    my $output = $database\->run_command(
\&        [ some_command => 1 ],
\&        $read_preference,
\&        $options
\&    );
.Ve
.PP
This method runs a database command.  The first argument must be a document
with the command and its arguments.  It should be given as an array reference
of key-value pairs or a Tie::IxHash object with the command name as the
first key.  An error will be thrown if the command is not an
ordered document.
.PP
By default, commands are run with a read preference of 'primary'.  An optional
second argument may specify an alternative read preference.  If given, it must
be a MongoDB::ReadPreference object or a hash reference that can be used to
construct one.
.PP
A hashref of options may also be provided.
.PP
Valid options include:
.IP "\(bu" 4
\&\f(CW\*(C`session\*(C'\fR \- the session to use for these operations. If not supplied, will use an implicit session. For more information see MongoDB::ClientSession
.PP
It returns the output of the command (a hash reference) on success or throws a
MongoDB::DatabaseError exception if
the command fails.
.PP
For a list of possible database commands, run:
.PP
.Vb 1
\&    my $commands = $db\->run_command([listCommands => 1]);
.Ve
.PP
There are a few examples of database commands in the
\&\*(L"\s-1DATABASE COMMANDS\*(R"\s0 in MongoDB::Examples section.  See also core documentation
on database commands: <http://dochub.mongodb.org/core/commands>.
.SS "watch"
.IX Subsection "watch"
Watches for changes on this database.
.PP
Perform an aggregation with an implicit initial \f(CW$changeStream\fR stage
and returns a MongoDB::ChangeStream result which can be used to
iterate over the changes in the database. This functionality is
available since MongoDB 4.0.
.PP
.Vb 3
\&    my $stream = $db\->watch();
\&    my $stream = $db\->watch( \e@pipeline );
\&    my $stream = $db\->watch( \e@pipeline, \e%options );
\&
\&    while (1) {
\&
\&        # This inner loop will only run until no more changes are
\&        # available.
\&        while (my $change = $stream\->next) {
\&            # process $change
\&        }
\&    }
.Ve
.PP
The returned stream will not block forever waiting for changes. If you
want to respond to changes over a longer time use \f(CW\*(C`maxAwaitTimeMS\*(C'\fR and
regularly call \f(CW\*(C`next\*(C'\fR in a loop.
.PP
See \*(L"watch\*(R" in MongoDB::Collection for details on usage and available
options.
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
David Golden <david@mongodb.com>
.IP "\(bu" 4
Rassi <rassi@mongodb.com>
.IP "\(bu" 4
Mike Friedman <friedo@friedo.com>
.IP "\(bu" 4
Kristina Chodorow <k.chodorow@gmail.com>
.IP "\(bu" 4
Florian Ragwitz <rafl@debian.org>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is Copyright (c) 2018 by MongoDB, Inc.
.PP
This is free software, licensed under:
.PP
.Vb 1
\&  The Apache License, Version 2.0, January 2004
.Ve

Zerion Mini Shell 1.0