diff --git a/source/whats-new.txt b/source/whats-new.txt index 33c3d1e3..b126620a 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -22,36 +22,6 @@ Learn what's new in: * :ref:`Version 6.1 ` * :ref:`Version 6.0 ` -* :ref:`Version 5.9 ` -* :ref:`Version 5.8 ` -* :ref:`Version 5.7 ` -* :ref:`Version 5.6 ` -* :ref:`Version 5.5 ` -* :ref:`Version 5.4 ` -* :ref:`Version 5.3 ` -* :ref:`Version 5.2 ` -* :ref:`Version 5.1 ` -* :ref:`Version 5.0 ` -* :ref:`Version 4.17 ` -* :ref:`Version 4.16 ` -* :ref:`Version 4.15 ` -* :ref:`Version 4.14 ` -* :ref:`Version 4.13 ` -* :ref:`Version 4.12 ` -* :ref:`Version 4.11 ` -* :ref:`Version 4.10 ` -* :ref:`Version 4.9 ` -* :ref:`Version 4.8 ` -* :ref:`Version 4.7 ` -* :ref:`Version 4.6 ` -* :ref:`Version 4.5 ` -* :ref:`Version 4.4 ` -* :ref:`Version 4.3 ` -* :ref:`Version 4.2 ` -* :ref:`Version 4.1 ` -* :ref:`Version 4.0 ` -* :ref:`Version 3.7 ` -* :ref:`Version 3.6 ` .. _version-6.1: @@ -154,931 +124,4 @@ The {+driver-short+} v6.0 release includes the following features: ` section of the Run a Command guide. To learn more about this release, see the -`v6.0.0 Release Highlights `__. - -.. _version-5.9: - -What's New in 5.9 ------------------ - -.. important:: Upgrade from v5.8 to v5.9 - - This version includes a fix to a memory leak introduced in v5.7. - We recommend upgrading to v5.9. - -The {+driver-short+} v5.9 release includes the following features: - -- Fixed a memory leak introduced in v5.7. - -- The ``Decimal128`` constructor and ``fromString()`` methods now throw an exception - when they detect a loss of precision of more than 34 significant digits. - The ``Decimal128`` class exposes a new ``fromStringWithRounding()`` static method that - uses the rounding behavior from previous versions of the driver. For more information, - see the `Release Notes for v5.5 of the js-bson package `__ - on GitHub. - -- Added support for detecting the ``AWS_STS_REGIONAL_ENDPOINTS`` and ``AWS_REGION`` - environment variables and setting the appropriate options when calling the - ``fromNodeProviderChain()`` method in the AWS SDK. - -To learn more about this release, see the -`v5.9.0 Release Highlights `__. - -.. _version-5.8: - -What's New in 5.8 ------------------ - -.. important:: Upgrade from v5.8 to v5.9 - - This version includes a fix to a memory leak introduced in v5.7. - We recommend upgrading to v5.9. - -The {+driver-short+} v5.8 release includes the following features: - -.. important:: Deprecation Notice - - The ``AutoEncrypter`` interface is deprecated. - -- Support for Kerberos versions 1.x and 2.x. - -- Deprecation errors are not emitted for the - ``tlsCertificateFile`` property when you set the - ``tlsCertificateKeyFile`` property. - -- Removes credential availability in the - ``ConnectionPoolCreatedEvent`` type. You can still access credentials - through the ``credentials`` property of a ``MongoOptions`` instance. - -- Lowers the ``@aws-sdk/credential-providers`` version to 3.188.0 - and ``zstd`` to ^1.0.0. - -To learn more about this release, see the -`v5.8.0 Release Highlights `__. - -.. _version-5.7: - -What's New in 5.7 ------------------ - -The {+driver-short+} v5.7 release includes the following features: - -.. important:: Deprecation Notice - - - The following Write Concern options are deprecated: - - - ``wtimeout`` - - ``j`` - - ``fsync`` - - To specify the write concern behavior, use the ``wtimeoutMS`` and - ``journal`` options instead. To learn more about these options, see the - :ref:`` page. - - - SSL options and other transport encryption options are deprecated. - To learn more about the deprecated options and which options to use - instead, see the Legacy SSL options deprecated section in the - v5.7.0 Release Highlights linked at the end of this section. - -- A new option for compound operation methods. The - ``includeResultMetaData`` - option allows you to specify whether to include information about the - operation result. See the :ref:`Built-in Methods - ` section of the Compound Operations - guide for more information. - -- Support for change stream split events which enables processing change - stream documents that exceed the 16MB maximum BSON size limit. - -- An API to manage Search indexes from within your application. To - learn more, see :ref:`Search Indexes `. - -To learn more about this release, see the -`v5.7.0 Release Highlights `__. - -.. _version-5.6: - -What's New in 5.6 ------------------ - -The {+driver-short+} v5.6 release includes the following features: - -- The driver now supports Node.js v20. - -- The driver can return a cursor as the response to a server command when you - call the ``runCursorCommand()`` method. To learn more about this feature, - see the `runCursorCommand API documentation <{+api+}/classes/Db.html#runCursorCommand>`__. - -- Support for specifying time series collection creation options - `bucketMaxSpanSeconds <{+api+}/interfaces/TimeSeriesCollectionOptions.html#bucketMaxSpanSeconds>`__ - and - `bucketRoundingSeconds <{+api+}/interfaces/TimeSeriesCollectionOptions.html#bucketRoundingSeconds>`__. - To learn more about these time series collection options, see - `Set Granularity for Time Series Data `__ - in the Server manual. - -To learn more about this release, see the `v5.6.0 Release Highlights `__. - -.. _version-5.5: - -What's New in 5.5 ------------------ - -New features of the 5.5 {+driver-short+} release include: - -- The driver now accurately detects Function-as-a-Service (FaaS) - environments in AWS by considering AWS environment variables only if - they begin with ``AWS_Lambda_``. -- You must upgrade ``mongodb-client-encryption`` to version 2.8.0 or - later if you want to create an encrypted collection by using the - Queryable Encryption feature. - -To learn more about this release, see the `v5.5.0 Release Highlights -`__. - -.. _version-5.4: - -What's New in 5.4 ------------------ - -New features of the 5.4 {+driver-short+} release include: - -.. important:: Deprecation Notice - - - The ``collStats`` operation is deprecated. Use the :manual:`$collStats - ` aggregation operator instead. - - The TypeScript interface passed to the ``db.command()`` method incorrectly - includes certain options. These options have been deprecated. - -- The ``ChangeStream.tryNext`` method now uses the schema-specific - ``TChange`` generic type instead of the ``Document`` interface. - -To learn more, see the `v5.4.0 Release Highlights -`__. - -.. _version-5.3: - -What's New in 5.3 ------------------ - -New features of the 5.3 {+driver-short+} release include: - -.. important:: Deprecation Notice - - - The ``forEach()`` cursor method, which allows you to iteratively access - results from queries and aggregations, is deprecated. Use the - ``for await...of`` syntax instead, as shown - :ref:`here. ` - - The ``addUser()`` method is deprecated. Use ``createUser()`` instead. - - The ``keepAlive`` and ``keepAliveInitialDelay`` connection options are - deprecated. - - Methods that contain duplicated functionality in the ``BulkWriteResult`` class are deprecated. - See the - `API documentation `__ - for a full list of deprecated methods and the preferred alternatives. - -- Client metadata now includes function as a service (FaaS) environment information - and alternative runtime detection. -- The driver now allows SRV record addresses that contain a trailing dot. -- ``UpdateResult.upsertedId`` now returns null when no documents are updated. - -To learn more, see the `v5.3.0 Release Highlights -`__. - -.. _version-5.2: - -What's New in 5.2 ------------------ - -New features of the 5.2 {+driver-short+} release include: - -- The driver now supports automatically obtaining Azure credentials when using - automatic Queryable Encryption. - -To learn more, see the `v5.2.0 Release Highlights -`__. - -.. _version-5.1: - -What's New in 5.1 ------------------ - -New features of the 5.1 {+driver-short+} release include: - -- The driver now supports automatic serialization of JavaScript ``bigint`` to - ``BSON.Long``. It also supports the deserialization of ``BSON.Long`` values returned - from the server to ``bigint`` values when the ``useBigInt64`` flag is passed - as true. - -To learn more, see the `v5.1.0 Release Highlights -`__. - -.. _version-5.0: - -What's New in 5.0 ------------------ - -.. warning:: Breaking Changes in v5.0 - - This driver version introduces breaking changes. For a list of these changes, see - the :ref:`Version 5.0 Breaking Changes section ` in the - Upgrade guide. - -New features of the 5.0 {+driver-short+} release include: - -- By default, the driver no longer checks types referenced in dot notation - unless the ``StrictFilter`` type annotation is explicitly - used. To learn more about this change, see the :ref:`Typescript fundamentals - page `. - - .. note:: - - This change is for Typescript only, and does not affect queries or operations - at runtime. - -- Optional installation of ``@aws-sdk/credential-providers`` as a peer dependency. - - - The driver no longer includes AWS SDK modules by default. Use the - following ``npm`` command to install the SDK: - - .. code-block:: bash - - npm install --save "@aws-sdk/credential-providers@^3.201.0" - - If you install the SDK, ``npm`` notifies you if the version of the SDK you - installed is incompatible with the driver. Once you install the - dependency successfully, the driver uses the AWS SDK itself to - manage credentials from the environment. - -.. _version-4.17: - -What's New in 4.17 ------------------- - -New features of the 4.17 {+driver-short+} release include: - -- Adds the ``mongodb-js/saslprep`` package as a driver dependency. -- Improves compatibility with the Queryable Encryption feature. - -To learn more, see the `v4.17.0 Release Highlights -`__. - -.. _version-4.16: - -What's New in 4.16 ------------------- - -New features of the 4.16 {+driver-short+} release include: - -- Includes Function-as-a-Service (FaaS) platform information in the driver - handshake metadata. -- Identifies Deno runtime usage in the client metadata. - -To learn more, see the `v4.16.0 Release Highlights -`__. - -.. _version-4.15: - -What's New in 4.15 ------------------- - -New features of the 4.15 {+driver-short+} release include: - -- Support for AWS IAM roles for service accounts. - -To learn more, see the `v4.15.0 Release Highlights -`__. - -.. _version-4.14: - -What's New in 4.14 ------------------- - -.. important:: Upgrade from v4.13 to v4.14 - - This version includes a fix to a memory leak introduced in v4.13. - We recommend upgrading to v4.14. - -New features of the 4.14 {+driver-short+} release include: - -- Fixed a memory leak introduced in v4.13. -- Deprecated methods and options that reference the legacy Logger. - -.. _version-4.13: - -What's New in 4.13 ------------------- - -New features of the 4.13 {+driver-short+} release include: - -- Automatic cancellation of in-flight operations in the connection pool when - the driver encounters network timeout errors. -- Disabled causal consistency in implicit sessions to prevent conflicting - with the ``linearizable`` and ``available`` read concern settings. -- Fixed a potential memory leak by ensuring that the driver destroys - ``MessageStream`` instances whenever their connections are destroyed. - -.. _version-4.12: - -What's New in 4.12 ------------------- - -.. important:: Upgrade Driver to Version 4.12.1 - - The 4.12.1 {+driver-short+} includes a fix to a regression in monitoring logic - that could cause processes to crash. - -New features of the 4.12 {+driver-short+} release include: - -- Redefinition of the ``ChangeStream`` class as an async iterable. - You can use ``ChangeStream`` instances in any context that expects an - ``AsyncIterator``. - - - Notably, change streams can now be used in Javascript ``for-await`` - loops: - - .. code-block:: js - :copyable: false - - const changeStream = myColl.watch(); - for await (const change of changeStream) { - console.log("Received change: ", change); - } - -- Fix to server monitoring when the driver skips monitoring events. In - this release, the driver always updates its view of the topology when - processing monitoring events. - -- Performance improvements with buffering as a result of modification to - data structures used internally in the driver. - -To learn more, see the `v4.12.0 Release Highlights `__. - -.. _version-4.11: - -What's New in 4.11 ------------------- - -Prioritization Order in Monitoring -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -When connecting to MongoDB Server version 6.0 or later, the driver prioritizes -``electionId`` settings before ``setVersion`` settings during Server Discovery and -Monitoring events. In previous versions, the prioritization order was reversed. - -Changes to AWS Authentication -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -When you install the optional ``aws-sdk/credential-providers`` -dependency, the driver uses the AWS SDK to retrieve AWS credentials from the -environment. - -To learn more about this behavior, see the :ref:`MONGODB-AWS -` section of the Authentication Mechanisms guide. - -Mutually Recursive Schema Type Checking -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This release includes added support for **mutually -recursive** collection schema types. The driver also provides type safety for -dot-notation queries up to a depth of eight in this release. At a depth greater -than or equal to eight, Typescript successfully compiles your code but does not -provide type safety. This depth limit on recursive types is a current limitation -of TypeScript. - -Example -``````` - -Suppose we have a collection of type ``Collection`` that contains the -following mutually recursive types: - -.. code-block:: js - :copyable: false - - interface Author { - name: string; - bestBook: Book; - } - - interface Book { - title: string; - author: Author; - } - -TypeScript enforces type checking up to a depth of eight. The following -code causes a TypeScript compilation error because the ``name`` property -value must be a ``string`` type: - -.. code-block:: js - :copyable: false - - myColl.findOne({ 'bestBook.author.bestBook.title': 25 }); - -At a depth greater than or equal to eight, TypeScript compiles your code but no -longer type checks it. For example, the following code assigns a ``number`` to a -``string`` property but does not cause a compilation error because the -referenced property is at a depth of 10: - -.. code-block:: js - :copyable: false - - myColl.findOne({ - 'bestBook.author.bestBook.author.bestBook.author.bestBook.author.bestBook.author.name': 25 - }); - -To learn more, see the `v4.11.0 Release Highlights `__. - -.. _version-4.10: - -What's New in 4.10 ------------------- - -New features of the 4.10 {+driver-short+} release include: - -- Callback Deprecation - - - Callbacks are now deprecated in favor of Promises. Callbacks will - be removed in the next major release. The Node driver team recommends - migrating to promises where possible: - - - Use ``async/await`` syntax. - - Use the Node.js `callbackify utility `__: - - .. code-block:: js - - require('util').callbackify(() => myColl.findOne())(callback) - - - Use :mdn:`then ` syntax: - - .. code-block:: js - - myColl.findOne().then(res => callback(null, res), err => callback(err)) - - - If you are unable to migrate to Promises in a large codebase, you can - use the legacy `{+driver-short+} with optional callback support `__. - -To learn more, see `v4.10.0 Release Highlights `__. - -.. _version-4.9: - -What's New in 4.9 ------------------ - -New features of the 4.9 {+driver-short+} release include: - -- Fixed an inconsistency with ``writeConcern`` options in the type definitions. -- Included the latest BSON release, which adds automatic UUID support. See the - BSON release notes `here `__. - -To learn more, see `v4.9.0 Release Highlights `__. - -.. _version-4.8: - -What's New in 4.8 ------------------ - -.. important:: Upgrade from v4.8.0 to v4.8.1 - - Version 4.8.1 fixes a type regression issue introduced in v4.8.0. By - upgrading to v4.8.1, you can specify ``_id`` values and sub-documents - when performing updates with the ``$set`` or ``$setOnInsert`` operators. - -New features of the 4.8 {+driver-short+} release include: - -- Added auto-completion and type safety for nested keys in an update filter -- ``client.startSession()`` can now be called before connecting to MongoDB -- ``estimatedDocumentCount()`` method can now accept a comment - -To learn more, see `v4.8.0 Release Highlights `__. - -.. _version-4.7: - -What's New in 4.7 ------------------ - -New features of the 4.7 {+driver-short+} release include: - -- The ``MongoClient.connect()`` method is now optional when connecting to your MongoDB instance -- Ability to compress messages with the ``Zstandard`` :ref:`compression algorithm ` -- Added support for the ``maxConnecting`` connection option -- Ability for change stream documents to show your documents before and after an update -- Added support for new change stream fields related to Cluster to Cluster Replication -- The ``estimatedDocumentCount()`` method now uses the ``$count`` database command -- Improved connecting to MongoDB in the AWS Lambda Init phase - -.. important:: Deprecation Notice - - The ``ResumeOptions`` interface is deprecated. Use the - ``ChangeStreamCursorOptions`` interface instead. - -.. _version-4.6: - -What's New in 4.6 ------------------ - -New features of the 4.6 Node.js driver release include: - -- Improved the ``ChangeStreamDocument`` in TypeScript. -- Even distribution of server selection based on load across servers. - -To learn more, see `v4.6.0 Release Highlights `__. - -.. _version-4.5: - -What's New in 4.5 ------------------ - -See `v4.5.0 Release Highlights `__ -on GitHub. - - -.. _version-4.4: - -What's New in 4.4 ------------------ - -New features of the 4.4 Node.js driver release include: - -- KMIP provider support when using CSFLE. -- TLS support when using CSFLE. -- Hostname canonicalization now accepts "none", "forward", and "forwardAndReverse" as ``authMechanismProperties`` when using GSSAPI. -- In the 4.0.0 release of the driver, the deprecated ``collection.count()`` method was inadvertently changed to behave like ``collection.countDocuments()``. - In this release, the ``collection.count()`` method is updated to match legacy behavior: - - - If a query is provided, ``collection.count()`` behaves the same as ``collection.countDocuments()`` and performs a collection scan. - - If no query is provided, ``collection.count()`` behaves the same as ``collection.estimatedDocumentCount()`` and relies on - collection metadata. - - .. important:: Deprecation Notice - - The ``cursor.count()`` method is deprecated and will be removed in the next major version, along with ``collection.count()``. - Use the ``collection.estimatedDocumentCount()`` or ``collection.countDocuments()`` - methods instead. - -.. _version-4.3: - -What's New in 4.3 ------------------ - -New features of the 4.3 Node.js driver release include: - -- SOCKS5 support -- Option to :ref:`disable UTF-8 validation ` -- Type inference for nested documents - -.. _version-4.2: - -What's New in 4.2 ------------------ - -New features of the 4.2 Node.js driver release include: - -- ``srvMaxHosts`` and ``srvServiceName`` DNS seedlist :ref:`connection options ` - -.. _version-4.1: - -What's New in 4.1 ------------------ - -New features of the 4.1 Node.js driver release include: - -- Added load balanced connection support for all cluster types including - the beta :ref:`Serverless platform `. -- Added support for the ``advanceClusterTime()`` method to determine if - the ``ClientSession`` should update its cluster time. - -.. _version-4.0: - -What's New in 4.0 ------------------ - -.. warning:: Breaking Changes in v4.0 - - This driver version introduces breaking changes. For a list of these changes, see - the :ref:`Version 4.0 Breaking Changes section ` in - the Upgrade guide. - -New features of the 4.0 Node.js driver release include: - -.. important:: - - In this release of the driver, the deprecated ``collection.count()`` method was - inadvertently changed to behave like ``collection.countDocuments()``. This behavior - is corrected in :ref:`version 4.4 `. - -TypeScript -~~~~~~~~~~ - -- We've migrated the driver to TypeScript. You can now harness the type - hinting and intellisense features in editors that support it to develop - your MongoDB applications. Enjoy the benefits of this work in pure JavaScript - projects as well. - -- The underlying BSON library used by this version is now migrated to - TypeScript. - -- Inline documentation is now consistently formatted to improve display - in editors. - -- If you are a user of the community types ``@types/mongodb``, there will - **likely be issues** adopting the types from our codebase. We could not - achieve a one to one match in types due to the details of writing the - codebase in TypeScript. - -We'd love to hear your TypeScript related feature requests. Please submit -ideas on our `JIRA project here `__. - -Key Changes -~~~~~~~~~~~ - -Node.js Version -``````````````` - -The minimum supported version of Node.js is now v12.9 or greater for -version 4 of the driver. Support for our 3.x branches will continue -until mid-year 2022 to allow time for users to upgrade. - -.. note:: - - 3.x supports back to Node.js v4. - - -Cursor Improvements -``````````````````` - -Our Cursor implementation is now updated to make it clear what is possible -before and after execution of an operation. - -.. example:: - - .. code-block:: js - :copyable: False - - const fc = myColl.find({a: 2.3}).skip(1) - for await (const doc of fc) { - console.log(doc) - fc.limit(1) // incorrect usage, cursor already executing - } - -There was inconsistency surrounding how the cursor would error if a -setting was applied after cursor execution began. Now, the cursor will -throw an error when attempting to apply operations in an invalid state, -similar to the following: - -``MongoError: Cursor is already initialized`` - -- Affected classes: - - - ``AbstractCursor`` - - ``FindCursor`` - - ``AggregationCursor`` - - ``ChangeStreamCursor`` (This is the underlying cursor for ``ChangeStream``) - - ``ListCollectionsCursor`` - -Cursor Stream API -+++++++++++++++++ - -Our Cursor types no longer extend ``Readable`` directly. They must be -transformed into a stream by calling ``cursor.stream()``. - -.. example:: - - .. code-block:: js - :copyable: False - - const cursor = myColl.find({}); - const stream = cursor.stream(); - stream.on("data", data => console.log); - stream.on("error", () => client.close()); - -Use ``hasNext()`` and ``next()`` for manual iteration. -Use ``for await of`` syntax or any ``Promise`` helpers for -asynchronous iteration. - -``MongoClientOptions`` Interface -```````````````````````````````` - -With type hinting, you should find that options passed to a ``MongoClient`` -are enumerated and discoverable. We've made a large effort to process -all options in the driver to give early warnings about incompatible settings -to get your app up and running in a correct state quickly. - -- ``checkServerIdentity`` is no longer checked before being passed to the - underlying Node API. Previously, accepted values were ``false``, or - a function. Now, the argument must be a function. Specifying a - boolean will result in an error being thrown. - -- It is no longer required to specify ``useUnifiedTopology`` or ``useNewUrlParser``. - -``createCollection()`` -`````````````````````` - -This method no longer supports a ``strict`` option, which returned -an error if the collection did not exist. To assert the existence of -a collection, use the ``listCollections()`` method instead. - -.. example:: - - .. code-block:: js - - const collections = (await db.listCollections({}, { nameOnly: true }) - .toArray()).map( - ({name}) => name - ); - if (!collections.includes(myNewCollectionName)) { - throw new Error(`${myNewCollectionName} doesn't exist`); - } - -``BulkWriteError`` → ``MongoBulkWriteError`` -```````````````````````````````````````````` - -``BulkWriteError`` is now renamed to ``MongoBulkWriteError``. - -When running bulk operations that make writes you can encounter errors -depending on your settings. Import the new class name ``MongoBulkWriteError`` -when testing for errors in bulk operations. - -``DB`` -`````` - -``DB`` is no longer an ``EventEmitter``. Listen for events directly from your -``MongoClient`` instance. - -``Collection.group()`` -`````````````````````` - -The ``Collection.group()`` helper, deprecated since MongoDB 3.4, -is now removed. Use the aggregation pipeline :manual:`$group ` -operator instead. - -Authentication -`````````````` - -- ``gssapiServiceName`` is now removed. Use `authMechanismProperties.SERVICE_NAME <{+api+}/interfaces/MongoClientOptions.html#authMechanismProperties>`__ in the URI or as an option on ``MongoClientOptions``. - - .. example:: - - .. code-block:: js - - ?authMechanismProperties.SERVICE_NAME - // or - new MongoClient(url, { SERVICE_NAME: "alternateServiceName" }) - -- Specifying username and password as options is only supported in the URI - or as an option on ``MongoClientOptions``. - - .. example:: - - .. code-block:: js - - new MongoClient("mongodb://:@") - // or - new MongoClient(url, { auth: { username: "", password: "" } }) - -``GridStore`` Removal -````````````````````` - -The GridStore API (already deprecated in 3.x) is now replaced with ``GridFSBucket``. -For more information on ``GridFS``, see the :manual:`mongodb manual `. - -Below are some snippets that represent equivalent operations. - -Construction -++++++++++++ - -.. example:: - - .. code-block:: javascript - - // old way - const gs = new GridStore(db, filename, mode[, options]) - // new way - const bucket = new GridFSBucket(client.db('test')[,options]) - -File Seeking -++++++++++++ - -GridFSBucket uses the Node.js Stream API. You can replicate file seeking -by using the ``start`` and ``end`` options, creating a download stream -from your ``GridFSBucket``. - -.. example:: - - .. code-block:: js - - bucket.openDownloadStreamByName(filename, { start: 0, end: 100 }) - -File Upload & Download -++++++++++++++++++++++ - -.. example:: - - .. code-block:: javascript - - await client.connect(); - const filename = 'test.txt'; // whatever local file name you want - const db = client.db(); - const bucket = new GridFSBucket(db); - - fs.createReadStream(filename) - .pipe(bucket.openUploadStream(filename)) - .on('error', console.error) - .on('finish', () => { - console.log('done writing to db!'); - - bucket - .find() - .toArray() - .then(files => { - console.log(files); - - bucket - .openDownloadStreamByName(filename) - .pipe(fs.createWriteStream('downloaded_' + filename)) - .on('error', console.error) - .on('finish', () => { - console.log('done downloading!'); - client.close(); - }); - }); - }); - -.. note:: - - ``GridFSBucket`` does not need to be closed like ``GridStore``. - -File Deletion -+++++++++++++ - -.. example:: - - .. code-block:: js - - // old way - GridStore.unlink(db, name, callback); - // new way - bucket.delete(file_id); - -Finding File Metadata -+++++++++++++++++++++ - -File metadata that used to be accessible on the ``GridStore`` instance can be -found by querying the bucket. - -.. example:: - - .. code-block:: js - - const fileMetaDataList: GridFSFile[] = bucket.find({}).toArray(); - -Unified Topology -```````````````` - -- We internally now only manage a ``unifiedTopology`` when you connect - to a ``mongod``. The differences between this and previous versions - is `detailed here `__. - -- It is no longer required to specify ``useUnifiedTopology`` or ``useNewUrlParser``. - -- You must use the new ``directConnection`` `option <{+api+}/interfaces/MongoClientOptions.html#directConnection>`__ - to connect to uninitialized replica set members. - -Explain -``````` - -Support is now added for fine-grained verbosity modes. You can learn more -about each mode :manual:`here `. - -Command Monitoring -`````````````````` - -The ``instrument()`` method is now removed. Use command monitoring instead. -See our guide on :doc:`command monitoring ` -for more information. - -.. _version-3.7: - -What's New in 3.7 ------------------ - -New features of the 3.7 Node.js driver release include: - -- Added support for load balancer mode while enabling the ``useUnifiedTopology`` option -- Added support for :ref:`{+stable-api+} ` while enabling the ``useUnifiedTopology`` option - -.. _version-3.6: - -What's New in 3.6 ------------------ - -New features of the 3.6 Node.js driver release include: - -- Added support for the :ref:`MONGODB-AWS ` authentication mechanism using Amazon Web Services (AWS) Identity and Access Management (IAM) credentials -- The `find() <{+api+}/classes/Collection.html#find>`__ method supports ``allowDiskUse()`` for sorts that require too much memory to execute in RAM -- The :ref:`update() ` and :ref:`replaceOne() ` methods support index hints -- A reduction in recovery time for topology changes and failover events -- Improvements in validation testing for the default :manual:`writeConcern ` -- Authentication requires fewer round trips to the server, resulting in faster connection setup -- Shorter Salted Challenge Response Authentication Mechanism (:manual:`SCRAM `) conversations -- Ability to create collections and indexes for multiple document transactions -- Running validation for a collection in the background +`v6.0.0 Release Highlights `__. \ No newline at end of file