.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" 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 >0, 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 .\" ======================================================================== .\" .IX Title "MongoDB::Upgrading::v1 3pm" .TH MongoDB::Upgrading::v1 3pm "2020-08-15" "perl v5.30.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::Upgrading::v1 \- Deprecations and behavior changes from v0 to v1 .SH "VERSION" .IX Header "VERSION" version v2.2.2 .SH "DESCRIPTION" .IX Header "DESCRIPTION" The v1 driver represents a substantial step forward in functionality and consistency. There are many areas where the old \s-1API\s0 has been deprecated or changed in a backward breaking way. .PP This document is intended to help developers update their code to take into account \s-1API\s0 changes from the v0 driver to the v1 driver. .SH "RATIONALE" .IX Header "RATIONALE" Changes to the driver were deemed necessary to achieve certain goals: .IP "\(bu" 4 consistency (intra-driver) – many parts of the v0 \s-1API\s0 were inconsistent, behaving differently from method to method; the v1 \s-1API\s0 minimizes developer surprises by improving consistency in return types and exception mechanisms. .IP "\(bu" 4 consistency (inter-driver) — \*(L"next-generation\*(R" MongoDB drivers across all languages are converging on common APIs and common behaviors; this simplifies developer education and support, as cross-language examples will be similar. .IP "\(bu" 4 encapsulation – too many low-level, internal operations were exposed as part of the \s-1API,\s0 which complicates maintenance work; the v1 \s-1API\s0 aims to minimize the \*(L"public surface\*(R" available to developers, allowing faster future development keeping up with MongoDB server enhancements with less risk of breakage. .IP "\(bu" 4 abstraction – many v0 methods returned raw server documents for end-user code to inspect, which is brittle in the face of changes in server responses over time; the v1 \s-1API\s0 uses result classes to abstract the details behind standardized accessors. .IP "\(bu" 4 server compatibility – some new features and behavior changes in the MongoDB server no longer fit the old driver design; the v1 driver transparently supports both old and new servers. .IP "\(bu" 4 portability – the v0 driver had a large dependency tree and substantial non-portable C code; the v1 driver removes some dependencies and uses widely-used, well-tested \s-1CPAN\s0 modules in place of custom C code where possible; it lays the groundwork for a future \*(L"pure-Perl optional\*(R" driver. .IP "\(bu" 4 round-trippable data – the v0 \s-1BSON\s0 implementation could easily change data types when round-tripping documents; the v1 driver is designed to round-trip data correctly whenever possible (within the limits of Perl's dynamic typing). .SH "INSTALLATION AND DEPENDENCY CHANGES" .IX Header "INSTALLATION AND DEPENDENCY CHANGES" .SS "Moo instead of Moose" .IX Subsection "Moo instead of Moose" The v1 driver uses Moo instead of Moose. This change results in a slightly faster driver and a significantly reduced deep dependency tree. .SS "\s-1SSL\s0 and \s-1SASL\s0" .IX Subsection "SSL and SASL" The v0 driver required a compiler and OpenSSL and libgsasl for \s-1SSL\s0 and \s-1SASL\s0 support, respectively. The v1 driver instead relies on \s-1CPAN\s0 modules \&\f(CW\*(C`IO::Socket::SSL\*(C'\fR and \f(CW\*(C`Authen::SASL\*(C'\fR for \s-1SSL\s0 and \s-1SASL\s0 support, respectively. .PP \&\s-1SSL\s0 configuration is now possible via the ssl attribute. .PP Authentication configuration is described in \*(L"\s-1AUTHENTICATION\*(R"\s0 in MongoDB::MongoClient. .SH "BEHAVIOR CHANGES" .IX Header "BEHAVIOR CHANGES" .SS "MongoClient configuration" .IX Subsection "MongoClient configuration" \fINew configuration options\fR .IX Subsection "New configuration options" .PP Several configuration options have been added, with particular emphasis on adding more granular control of timings and timeout behaviors. .IP "\(bu" 4 \&\f(CW\*(C`auth_mechanism\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`auth_mechanism_properties\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`bson_codec\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`connect_timeout_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`heartbeat_frequency_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`local_threshold_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`max_time_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`replica_set_name\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`read_pref_mode\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`read_pref_tag_sets\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`server_selection_timeout_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`socket_check_interval_ms\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`socket_timeout_ms\*(C'\fR .PP \fIReplica set configuration\fR .IX Subsection "Replica set configuration" .PP Connecting to a replica set now requires a replica set name, given either with the \f(CW\*(C`replica_set_name\*(C'\fR option for MongoDB::MongoClient or with the \f(CW\*(C`replicaSet\*(C'\fR option in a connection string. For example: .PP .Vb 4 \& $client = MongoDB::MongoClient\->new( \& host => "mongodb://rs1.example.com,rs2.example.com/", \& replica_set_name => \*(Aqthe_set\*(Aq, \& ); \& \& $client = MongoDB::MongoClient\->new( \& host => "mongodb://rs1.example.com,rs2.example.com/?replicaSet=the_set" \& ); .Ve .PP \fIConfiguration options changed to read-only\fR .IX Subsection "Configuration options changed to read-only" .PP Configuration options are changing to be immutable to prevent surprising action-at-a-distance. (E.g. changing an attribute value in some part of the code changes it for other parts of the code that didn't expect it.) Going forward, options may be set at MongoDB::MongoClient construction time only. .PP The following options have changed to be read-only: .IP "\(bu" 4 \&\f(CW\*(C`db_name\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`j\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`password\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`ssl\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`username\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`w\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`wtimeout\*(C'\fR .PP Write concern may be overridden at the MongoDB::Database and MongoDB::Collection level during construction of those objects. For more details, see the later section on write concern changes. .PP \fIMapping between connection string and configuration options\fR .IX Subsection "Mapping between connection string and configuration options" .PP Many configuration options may be set via a connection string \s-1URI\s0 in the \&\f(CW\*(C`host\*(C'\fR option. In the v0 driver, the precedence between the connection string and constructor options was completely inconsistent. In the v1 driver, options set via a connection string \s-1URI\s0 will take precedence over options passed to the constructor. This is consistent with with other MongoDB drivers (as well as how \s-1DBI\s0 treats Data Source Names). .PP The list of servers and ports as well as the optional \f(CW\*(C`username\*(C'\fR, \&\f(CW\*(C`password\*(C'\fR and \f(CW\*(C`db_name\*(C'\fR options come directly from \s-1URI\s0 structure. Other options are parsed as key-value parameters at the end of the connection string. The following table shows how connection string keys map to configuration options in the MongoDB::MongoClient: .PP .Vb 10 \& Connection String Key MongoClient option \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& authMechanism auth_mechanism \& authMechanismProperties auth_mechanism_properties \& connectTimeoutMS connect_timeout_ms \& heartbeatFrequencyMS heartbeat_frequency_ms \& journal j \& localThresholdMS local_threshold_ms \& maxTimeMS max_time_ms \& readPreference read_pref_mode \& readPreferenceTags read_pref_tag_sets \& replicaSet replica_set_name \& serverSelectionTimeoutMS server_selection_timeout_ms \& socketCheckIntervalMS socket_check_interval_ms \& socketTimeoutMS socket_timeout_ms \& ssl ssl \& w w \& wTimeoutMS wtimeout .Ve .PP The \f(CW\*(C`readPreferenceTags\*(C'\fR and \f(CW\*(C`authMechanismProperties\*(C'\fR keys take colon-delimited, comma-separated pairs: .PP .Vb 2 \& readPreferenceTags=dc:nyeast,rack:1 \& authMechanismProperties=SERVICE_NAME:mongodb .Ve .PP The \f(CW\*(C`readPreferenceTags\*(C'\fR option may be repeated to build up a list of tag set documents: .PP .Vb 1 \& readPreferenceTags=dc:nyc,rack:1&readPreferenceTags=dc:nyc .Ve .PP \fIDeprecated configuration options\fR .IX Subsection "Deprecated configuration options" .PP Several options have been superseded, replaced or renamed for clarity and are thus deprecated and undocumented. They are kept for a limited degree of backwards compatibility. They will be generally be used as fallbacks for other options. If any were read-write, they have also been changed to read-only. .IP "\(bu" 4 \&\f(CW\*(C`dt_type\*(C'\fR — see \*(L"\s-1BSON\s0 encoding changes\*(R" for details. .IP "\(bu" 4 \&\f(CW\*(C`query_timeout\*(C'\fR — replaced by \f(CW\*(C`socket_timeout_ms\*(C'\fR; if set, this will be used as a fallback default for \f(CW\*(C`socket_timeout_ms\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`sasl\*(C'\fR — superseded by \f(CW\*(C`auth_mechanism\*(C'\fR; if set, this will be used along with \f(CW\*(C`sasl_mechanism\*(C'\fR as a fallback default for \f(CW\*(C`auth_mechanism\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`sasl_mechanism\*(C'\fR — superseded by \f(CW\*(C`auth_mechanism\*(C'\fR; if set, this will be used as a fallback default for \f(CW\*(C`auth_mechanism\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`timeout\*(C'\fR — replaced by \f(CW\*(C`connect_timeout_ms\*(C'\fR; if set, this will be used as a fallback default for \f(CW\*(C`connect_timeout_ms\*(C'\fR. .PP These will be removed in a future major release. .PP \fIConfiguration options removed\fR .IX Subsection "Configuration options removed" .PP Some configuration options have been removed entirely, as they no longer serve any purpose given changes to server discovery, server selection and connection handling: .IP "\(bu" 4 \&\f(CW\*(C`auto_connect\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`auto_reconnect\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`find_master\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`max_bson_size\*(C'\fR .PP As described further below in the \*(L"\s-1BSON\s0 encoding changes\*(R" section, these \&\s-1BSON\s0 encoding configuration options have been removed as well: .IP "\(bu" 4 \&\f(CW\*(C`inflate_dbrefs\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`inflate_regexps\*(C'\fR .PP Removed configuration options will be ignored if passed to the MongoDB::MongoClient constructor. .SS "Lazy connections and reconnections on demand" .IX Subsection "Lazy connections and reconnections on demand" The improved approach to server monitoring and selection allows all connections to be lazy. When the client is constructed, no connections are made until the first network operation is needed. At that time, the client will scan all servers in the seed list and begin regular monitoring. Connections that drop will be re-established when needed. .PP \&\fB\s-1IMPORTANT:\s0\fR Code that used to rely on a fatal exception from \&\f(CW\*(C`MongoDB::MongoClient\->new\*(C'\fR when no mongod is available will break. Instead, users are advised to just conduct their operations and be prepared to handle errors. .PP For testing, users may wish to run a simple command to check that a mongod is ready: .PP .Vb 1 \& use Test::More; \& \& # OLD WAY: BROKEN \& plan skip_all => \*(Aqno mongod\*(Aq unless eval { \& MongoDB::MongoClient\->new \& }; \& \& # NEW WAY 1: with MongoDB::MongoClient \& plan skip_all => \*(Aqno mongod\*(Aq unless eval { \& MongoDB::MongoClient\->new\->db(\*(Aqadmin\*(Aq)\->run_command( \& [ ismaster => 1 ] \& ) \& }; \& \& # NEW WAY 2: with MongoDB and connect \& plan skip_all => \*(Aqno mongod\*(Aq unless eval { \& MongoDB\->connect\->db(\*(Aqadmin\*(Aq)\->run_command([ ismaster => 1 ]) \& }; .Ve .PP See \s-1SERVER SELECTION\s0 and \s-1SERVER MONITORING AND FAILOVER\s0 in MongoDB::MongoClient for details. .SS "Exceptions are the preferred error handling approach" .IX Subsection "Exceptions are the preferred error handling approach" In the v0 driver, errors could be indicated in various ways: .IP "\(bu" 4 boolean return value .IP "\(bu" 4 string return value is an error; hash ref is success .IP "\(bu" 4 document that might contain an 'err', 'errmsg' or '$err' field .IP "\(bu" 4 thrown string exception .PP Regardless of the documented error handling, every method that involved a network operation would throw an exception on various network errors. .PP In the v1 driver, exceptions objects are the standard way of indicating errors. The exception hierarchy is described in MongoDB::Error. .SS "Cursors and query responses" .IX Subsection "Cursors and query responses" In v0, MongoDB::Cursor objects were used for ordinary queries as well as the query-like commands aggregation and parallel scan. However, only cursor iteration commands worked for aggregation and parallel scan \&\*(L"cursors\*(R"; the rest of the MongoDB::Cursor \s-1API\s0 didn't apply and was fatal. .PP In v1, all result iteration is done via the new MongoDB::QueryResult class. MongoDB::Cursor is now just a thin wrapper that holds query parameters, instantiates a MongoDB::QueryResult on demand, and passes iteration methods through to the query result object. .PP This significantly simplifies the code base and should have little end-user visibility unless users are specifically checking the return type of queries and query-like methods. .PP The \f(CW\*(C`explain\*(C'\fR cursor method no longer resets the cursor. .PP The \f(CW\*(C`slave_okay\*(C'\fR cursor method now sets the \f(CW\*(C`read_preference\*(C'\fR to 'secondaryPreferred' or clears it to 'primary'. .PP The \f(CW\*(C`snapshot\*(C'\fR cursor method now requires a boolean argument, allowing it to be turned on or off before executing the query. Calling it without an argument (as it was in v0) is a fatal exception. .PP Parallel scan \*(L"cursors\*(R" are now QueryResult objects, with the same iteration methods as in v0. .PP The \f(CW$MongoDB::Cursor::slave_okay\fR global variable has been removed as part of the revision to read preference handling. See the read preferences section below for more details. .PP The \f(CW$MongoDB::Cursor::timeout\fR global variable has also been removed. Timeouts are set during MongoDB::MongoClient configuration and are immutable. See the section on configuration changes for more. .SS "Aggregation \s-1API\s0" .IX Subsection "Aggregation API" On MongoDB 2.6 or later, \f(CW\*(C`aggregate\*(C'\fR always uses a cursor to execute the query. The \f(CW\*(C`batchSize\*(C'\fR option has been added (but has no effect prior to 2.6). The \f(CW\*(C`cursor\*(C'\fR option is deprecated. .PP The return types for the \f(CW\*(C`aggregate\*(C'\fR method are now \fBalways\fR QueryResult objects, regardless of whether the aggregation uses a cursor internally or is an 'explain'. .PP \&\fB\s-1NOTE\s0\fR: To help users with a 2.6 mongos and mixed version shards with versions before 2.6, passing the deprecated 'cursor' option with a false value will disable the use of a cursor. This workaround is provided for convenience and will be removed when 2.4 is no longer supported. .SS "Read preference objects and the read_preference method" .IX Subsection "Read preference objects and the read_preference method" A new MongoDB::ReadPreference class is used to encapsulate read preference attributes. In the v1 driver, it is constructed from the \&\f(CW\*(C`read_pref_mode\*(C'\fR and \f(CW\*(C`read_pref_tag_sets\*(C'\fR attributes on MongoDB::MongoClient: .PP .Vb 4 \& MongoDB::MongoClient\->new( \& read_pref_mode => \*(AqprimaryPreferred\*(Aq, \& read_pref_tag_sets => [ { dc => \*(Aquseast\*(Aq }, {} ], \& ); .Ve .PP The old \f(CW\*(C`read_preference\*(C'\fR method to change the read preference has been removed and trying to set a read preference after the client has been created is a fatal error. The old mode constants \s-1PRIMARY, SECONDARY,\s0 etc. have been removed. .PP The \f(CW\*(C`read_preference\*(C'\fR method now returns the MongoDB::ReadPreference object generated from \f(CW\*(C`read_pref_mode\*(C'\fR and \f(CW\*(C`read_pref_tag_sets\*(C'\fR. .PP It is inherited by MongoDB::Database, MongoDB::Collection, and MongoDB::GridFS objects unless provided as an option to the relevant factory methods: .PP .Vb 3 \& my $coll = $db\->get_collection( \& "foo", { read_preference => \*(Aqsecondary\*(Aq } \& ); .Ve .PP Such \f(CW\*(C`read_preference\*(C'\fR arguments may be a MongoDB::ReadPreference object, a hash reference of arguments to construct one, or a string that represents the read preference mode. .PP MongoDB::Database and MongoDB::Collection also have \f(CW\*(C`clone\*(C'\fR methods that allow easy alteration of a read preference for a limited scope. .PP .Vb 1 \& my $coll2 = $coll\->clone( read_preference => \*(AqsecondaryPreferred\*(Aq ); .Ve .PP For MongoDB::Cursor, the \f(CW\*(C`read_preference\*(C'\fR method sets a hidden read preference attribute that is used for the query in place of the MongoDB::MongoClient default \f(CW\*(C`read_preference\*(C'\fR attribute. This means that calling \f(CW\*(C`read_preference\*(C'\fR on a cursor object no longer changes the read preference globally on the client – the read preference change is scoped to the cursor object only. .SS "Write concern objects and removing the safe argument" .IX Subsection "Write concern objects and removing the safe argument" A new MongoDB::WriteConcern class is used to encapsulate write concern attributes. In the v1 driver, it is constructed from the \f(CW\*(C`w\*(C'\fR, \f(CW\*(C`wtimeout\*(C'\fR and \f(CW\*(C`j\*(C'\fR attributes on MongoDB::MongoClient: .PP .Vb 1 \& MongoDB::MongoClient\->new( w => \*(Aqmajority\*(Aq, wtimeout => 1000 ); .Ve .PP The \f(CW\*(C`write_concern\*(C'\fR method now returns the MongoDB::WriteConcern object generated from \f(CW\*(C`w\*(C'\fR, \f(CW\*(C`wtimeout\*(C'\fR and \f(CW\*(C`j\*(C'\fR. .PP It is inherited by MongoDB::Database, MongoDB::Collection, and MongoDB::GridFS objects unless provided as an option to the relevant factory methods: .PP .Vb 3 \& $db = $client\->get_database( \& "test", { write_concern => { w => \*(Aqmajority\*(Aq } } \& ); .Ve .PP Such \f(CW\*(C`write_concern\*(C'\fR arguments may be a MongoDB::WriteConcern object, a hash reference of arguments to construct one, or a string that represents the \f(CW\*(C`w\*(C'\fR mode. .PP MongoDB::Database and MongoDB::Collection also have \f(CW\*(C`clone\*(C'\fR methods that allow easy alteration of a write concern for a limited scope. .PP .Vb 1 \& my $coll2 = $coll\->clone( write_concern => { w => 1 } ); .Ve .PP The \f(CW\*(C`safe\*(C'\fR argument is no longer used in the new \s-1CRUD API.\s0 .SS "Authentication based only on configuration options" .IX Subsection "Authentication based only on configuration options" Authentication now happens automatically on connection during the \&\*(L"handshake\*(R" with any given server based on the auth_mechanism attribute. .PP The old \f(CW\*(C`authenticate\*(C'\fR method in MongoDB::MongoClient has been removed. .SS "Bulk \s-1API\s0" .IX Subsection "Bulk API" \fIBulk method names changed to match \s-1CRUD API\s0\fR .IX Subsection "Bulk method names changed to match CRUD API" .PP Method names match the new \s-1CRUD API,\s0 e.g. \f(CW\*(C`insert_one\*(C'\fR instead of \&\f(CW\*(C`insert\*(C'\fR and so one. The legacy names are deprecated. .PP \fIBulk insertion\fR .IX Subsection "Bulk insertion" .PP Insertion via the bulk \s-1API\s0 will \fB\s-1NOT\s0\fR insert an \f(CW\*(C`_id\*(C'\fR into the original document if one does not exist. Previous documentation was not specific whether this was the case or if the \f(CW\*(C`_id\*(C'\fR was added to the document sent to the server. .PP \fIBulk write results\fR .IX Subsection "Bulk write results" .PP The bulk write results class has been renamed to MongoDB::BulkWriteResult. It keeps \f(CW\*(C`MongoDB::WriteResult\*(C'\fR as an empty superclass for some backwards compatibility so that \f(CW\*(C`$result\->isa("MongoDB::WriteResult")\*(C'\fR will continue to work as expected. .PP The attributes have been renamed to be consistent with the new \s-1CRUD API.\s0 The legacy names are deprecated, but are available as aliases. .SS "GridFS" .IX Subsection "GridFS" The MongoDB::GridFS class now has explicit read preference and write concern attributes inherited from MongoDB::MongoClient or MongoDB::Database, just like MongoDB::Collection. This means that GridFS operations now default to an acknowledged write concern, just like collection operations have been doing since v0.502.0 in 2012. .PP The use of \f(CW\*(C`safe\*(C'\fR is deprecated. .PP Support for ancient, undocumented positional parameters circa 2010 has been removed. .SS "Low-level functions removed" .IX Subsection "Low-level functions removed" Low-level driver functions have been removed from the public \s-1API.\s0 .SS "MongoDB::Connection removed" .IX Subsection "MongoDB::Connection removed" The \f(CW\*(C`MongoDB::Connection\*(C'\fR module was deprecated in v0.502.0 and has been removed. .SS "\s-1BSON\s0 encoding changes" .IX Subsection "BSON encoding changes" In the v1 driver, \s-1BSON\s0 encoding and decoding have been encapsulated into a MongoDB::BSON codec object. This can be provided at any level, from MongoDB::MongoClient to MongoDB::Collection. If not provided, a default will be created that behaves similarly to the v0 encoding/decoding functions, except for the following changes. .PP \fI\f(CI$MongoDB::BSON::use_binary\fI removed\fR .IX Subsection "$MongoDB::BSON::use_binary removed" .PP Historically, this defaulted to false, which corrupts binary data when round tripping. Retrieving a binary data element and re-inserting it would have resulted in a field with \s-1UTF\-8\s0 encoded string of binary data. .PP Going forward, binary data will be returned as a MongoDB::BSON::Binary object. A future driver may add the ability to control decoding to allow alternative representations. .PP \fI\f(CI$MongoDB::BSON::use_boolean\fI removed\fR .IX Subsection "$MongoDB::BSON::use_boolean removed" .PP This global variable never worked. \s-1BSON\s0 booleans were always deserialized as boolean objects. A future driver may add the ability to control boolean representation. .PP \fI\f(CI$MongoDB::BSON::utf8_flag_on\fI removed\fR .IX Subsection "$MongoDB::BSON::utf8_flag_on removed" .PP In order to ensure round-tripping of string data, this variable is removed. \&\s-1BSON\s0 strings will always be decoded to Perl character strings. Anything else risks double-encoding a round-trip. .PP \fI\f(CI$MongoDB::BSON::looks_like_number\fI and \f(CI$MongoDB::BSON::char\fI deprecated and re-scoped\fR .IX Subsection "$MongoDB::BSON::looks_like_number and $MongoDB::BSON::char deprecated and re-scoped" .PP In order to allow a future driver to provide more flexible user-customized encoding and decoding, these global variables are deprecated. If set, they will be examined during \f(CW\*(C`MongoDB::MongoClient\->new()\*(C'\fR to set the configuration of a default MongoDB::BSON codec (if one is not provided). Changing them later will \fB\s-1NOT\s0\fR change the behavior of the codec object. .PP \fI\f(CI\*(C`MongoDB::MongoClient\*(C'\fI option \f(CI\*(C`inflate_regexps\*(C'\fI removed\fR .IX Subsection "MongoDB::MongoClient option inflate_regexps removed" .PP Previously, \s-1BSON\s0 regular expressions decoded to \f(CW\*(C`qr{}\*(C'\fR references by default and the \f(CW\*(C`MongoDB::MongoClient\*(C'\fR \f(CW\*(C`inflate_regexps\*(C'\fR option was available to decode instead to MongoDB::BSON::Regexps. .PP Going forward in the v1.0.0 driver, for safety and consistency with other drivers, \s-1BSON\s0 regular expressions \fBalways\fR decode to MongoDB::BSON::Regexp objects. .PP \fI\f(CI\*(C`MongoDB::MongoClient\*(C'\fI option \f(CI\*(C`inflate_dbrefs\*(C'\fI removed\fR .IX Subsection "MongoDB::MongoClient option inflate_dbrefs removed" .PP The \f(CW\*(C`inflate_dbrefs\*(C'\fR configuration option has been removed and replaced with a \f(CW\*(C`dbref_callback\*(C'\fR option in MongoDB::BSON. .PP By default, the \f(CW\*(C`MongoDB::MongoClient\*(C'\fR will create a MongoDB::BSON codec that will construct MongoDB::DBRef objects. This ensures that DBRefs properly round-trip. .PP \fI\f(CI\*(C`MongoDB::MongoClient\*(C'\fI option \f(CI\*(C`dt_type\*(C'\fI deprecated and changed to read-only\fR .IX Subsection "MongoDB::MongoClient option dt_type deprecated and changed to read-only" .PP The \f(CW\*(C`dt_type\*(C'\fR option is now only takes effect if \f(CW\*(C`MongoDB::MongoClient\*(C'\fR constructs a MongoDB::BSON codec object. It has been changed to a read-only attribute so that any code that relied on changing \f(CW\*(C`dt_type\*(C'\fR after constructing a \f(CW\*(C`MongoDB::MongoClient\*(C'\fR object will fail instead of being silently ignored. .PP \fIInt32 vs Int64 encoding changes\fR .IX Subsection "Int32 vs Int64 encoding changes" .PP On 64\-bit Perls, integers that fit in 32\-bits will be encoded as \s-1BSON\s0 Int32 (whereas previously these were always encoded as \s-1BSON\s0 Int64). .PP Math::BigInt objects will always be encoded as \s-1BSON\s0 Int64, which allows users to force 64\-bit encoding if desired. .PP \fIAdded support for Time::Moment\fR .IX Subsection "Added support for Time::Moment" .PP Time::Moment is a much faster replacement for the venerable DateTime module. The \s-1BSON\s0 codec will serialize Time::Moment objects correctly and can use that module as an argument for the \f(CW\*(C`dt_type\*(C'\fR codec attribute. .PP \fIAdded support for encoding common \s-1JSON\s0 boolean classes\fR .IX Subsection "Added support for encoding common JSON boolean classes" .PP Most \s-1JSON\s0 libraries on \s-1CPAN\s0 implement their own boolean classes. The following libraries boolean types will now encode correctly as \s-1BSON\s0 booleans: .IP "\(bu" 4 \&\s-1JSON::XS\s0 .IP "\(bu" 4 Cpanel::JSON::XS .IP "\(bu" 4 \&\s-1JSON::PP\s0 .IP "\(bu" 4 JSON::Tiny .IP "\(bu" 4 Mojo::JSON .SS "DBRef objects" .IX Subsection "DBRef objects" The \f(CW\*(C`fetch\*(C'\fR method and related attributes \f(CW\*(C`client\*(C'\fR, \f(CW\*(C`verify_db\*(C'\fR, and \&\f(CW\*(C`verify_coll\*(C'\fR have been removed from MongoDB::DBRef. .PP Providing a \f(CW\*(C`fetch\*(C'\fR method was inconsistent with other MongoDB drivers, which either never provided it, or have dropped it in the next-generation drivers. It requires a \f(CW\*(C`client\*(C'\fR attribute, which tightly couples \s-1BSON\s0 decoding to the client model, causing circular reference issues and triggering Perl memory bugs under threads. Therefore, the v1.0.0 driver no longer support fetching directly from MongoDB::DBRef; users will need to implement their own methods for dereferencing. .PP Additionally, the \f(CW\*(C`db\*(C'\fR attribute is now optional, consistent with the specification for DBRefs. .PP Also, all attributes (\f(CW\*(C`ref\*(C'\fR, \f(CW\*(C`id\*(C'\fR and \f(CW\*(C`db\*(C'\fR) are now read-only, consistent with the move toward immutable objects throughout the driver. .PP To support round-tripping DBRefs with additional fields other than \f(CW$ref\fR, \&\f(CW$id\fR and \f(CW$db\fR, the DBRef class now has an attribute called \f(CW\*(C`extra\*(C'\fR. As not all drivers support this feature, using it for new DBRefs is not recommended. .SH "DEPRECATED METHODS" .IX Header "DEPRECATED METHODS" Deprecated options and methods may be removed in a future release. Their documentation has been removed to discourage ongoing use. Unless otherwise stated, they will continue to behave as they previously did, allowing a degree of backwards compatibility until code is updated to the new MongoDB driver \s-1API.\s0 .SS "MongoDB::Database" .IX Subsection "MongoDB::Database" .IP "\(bu" 4 eval – MongoDB 3.0 deprecated the '$eval' command, so this helper method is deprecated as well. .IP "\(bu" 4 last_error — Errors are now indicated via exceptions at the time database commands are executed. .SS "MongoDB::Collection" .IX Subsection "MongoDB::Collection" .IP "\(bu" 4 insert, batch_insert, remove, update, save, query and find_and_modify — A new common driver \s-1CRUD API\s0 replaces these legacy methods. .IP "\(bu" 4 get_collection — This method implied that collections could be contained inside collection. This doesn't actually happen so it's confusing to have a Collection be a factory for collections. Users who want nested namespaces should be explicit and create them off Database objects instead. .IP "\(bu" 4 ensure_index, drop_indexes, drop_index, get_index — A new MongoDB::IndexView class is accessible through the \f(CW\*(C`indexes\*(C'\fR method, offering greater consistency in behavior across drivers. .IP "\(bu" 4 validate — The return values have changed over different server versions, so this method is risky to use; it has more use as a one-off tool, which can be accomplished via \f(CW\*(C`run_command\*(C'\fR. .SS "MongoDB::CommandResult" .IX Subsection "MongoDB::CommandResult" .IP "\(bu" 4 result — has been renamed to 'output' for clarity .SS "MongoDB::Cursor" .IX Subsection "MongoDB::Cursor" .IP "\(bu" 4 slave_ok — this modifier method is superseded by the 'read_preference' modifier method .IP "\(bu" 4 count — this is superseded by the \*(L"MongoDB::Collection#count\*(R" in MongoDB::Collection count method. Previously, this ignored skip/limit unless a true argument was passed, which was a bizarre, non-intuitive and inconsistent \s-1API.\s0 .SS "MongoDB::BulkWrite and MongoDB::BulkWriteView" .IX Subsection "MongoDB::BulkWrite and MongoDB::BulkWriteView" .IP "\(bu" 4 insert — renamed to 'insert_one' for consistency with \s-1CRUD API\s0 .IP "\(bu" 4 update — renamed to 'update_many' for consistency with \s-1CRUD API\s0 .IP "\(bu" 4 remove — renamed to 'delete_many' for consistency with \s-1CRUD API\s0 .IP "\(bu" 4 remove_one — renamed to 'delete_one' for consistency with \s-1CRUD API\s0 .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 David Golden .IP "\(bu" 4 Rassi .IP "\(bu" 4 Mike Friedman .IP "\(bu" 4 Kristina Chodorow .IP "\(bu" 4 Florian Ragwitz .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2020 by MongoDB, Inc. .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve