node-mongodb-native

The official MongoDB Node.js driver

APACHE-2.0 License

Downloads
25.2M
Stars
10K
Committers
461

Bot releases are visible (Hide)

node-mongodb-native - v5.8.0

Published by github-actions[bot] about 1 year ago

5.8.0 (2023-08-21)

The MongoDB Node.js team is pleased to announce version 5.8.0 of the mongodb package!

Release Notes

The AutoEncrypter interface has been deprecated

The AutoEncrypter interface was used internally but accidentally made public in the 4.x version of the driver. It is now deprecated and will be made internal in the next major release.

Kerberos support for 1.x and 2.x

Moves the kerberos dependency back to ^1.0.0 || ^2.0.0 to indicate support for both 1.x and 2.x. Support for 1.x is removed in 6.0.

Fixed accidental deprecation warning

Because of internal options handling, a deprecation was emitted for tlsCertificateFile when using tlsCertificateKeyFile. That has been corrected.

Remove credential availability on ConnectionPoolCreatedEvent

In order to avoid mistakenly printing credentials the ConnectionPoolCreatedEvent will replace the credentials option with an empty object. The credentials are still accessble via MongoClient options: client.options.credentials.

Features

  • NODE-5399: use mongodb-js/saslprep instead of saslprep (#3818) (c0d3927)
  • NODE-5429: deprecate the AutoEncrypter interface (#3764) (9bb0d95)
  • NODE-5465,NODE-5538: lower @aws-sdk/credential-providers version to 3.188.0 and zstd to ^1.0.0 (#3821) (39ff81d)

Bug Fixes

  • NODE-5489: set kerberos compatibility to ^1.0.0 || ^2.0.0 (#3803) (c3b35b3)
  • NODE-5495: do not emit deprecation warning when tlsCertificateKeyFile is specified and tlsCertificateFile is not (#3810) (e81d4a2)
  • NODE-5537: remove credentials from ConnectionPoolCreatedEvent options (#3813) (4cf1e96)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v4.17.0

Published by github-actions[bot] about 1 year ago

4.17.0 (2023-08-17)

The MongoDB Node.js team is pleased to announce version 4.17.0 of the mongodb package!

Release Notes

mongodb-js/saslprep is now installed by default

Until v6, the driver included the saslprep package as an optional dependency for SCRAM-SHA-256 authentication. saslprep breaks when bundled with webpack because it attempted to read a file relative to the package location and consequently the driver would throw errors when using SCRAM-SHA-256 if it were bundled.

The driver now depends on mongodb-js/saslprep, a fork of saslprep that can be bundled with webpack because it includes the necessary saslprep data in memory upon loading. This will be installed by default but will only be used if SCRAM-SHA-256 authentication is used.

Remove credential availability on ConnectionPoolCreatedEvent

In order to avoid mistakenly printing credentials the ConnectionPoolCreatedEvent will replace the credentials option with an empty object. The credentials are still accessble via MongoClient options: client.options.credentials.

Features

  • NODE-5272: do not create or drop ecc collections (#3678) (d26ad61)
  • NODE-5398: use mongodb-js/saslprep instead of saslprep (#3820) (5244711)

Bug Fixes

  • NODE-5262: AWS Lambda metadata detection logic is too permissive (#3683) (c0c3d99)
  • NODE-5311: construct error messages for AggregateErrors in Node16+ (#3683) (98b7bdf)
  • NODE-5316: prevent parallel topology creation in MongoClient.connect (#3696) (e13038d)
    • Thank you @clemclx for contributing this fix! 🎉
  • NODE-5356: prevent scram auth from throwing TypeError if saslprep is not a function (#3732) (2d028af)
  • NODE-5536: remove credentials from ConnectionPoolCreatedEvent options (#3812) (2910dca)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.7.0

Published by github-actions[bot] over 1 year ago

5.7.0 (2023-07-06)

The MongoDB Node.js team is pleased to announce version 5.7.0 of the mongodb package!

Release Notes

Write Concern legacy options deprecated

wtimeout, j, and fsync options have been deprecated, please use wtimeoutMS and journal instead.

Legacy SSL options deprecated

In an effort to simplify TLS setup and use with the driver we're paring down the number of custom options to the ones that are common to all drivers. This should reduce inadvertent misconfiguration due to conflicting options.

The legacy "ssl-" options have been deprecated, each has a corresponding "tls-" option listed in the table below (except for sslCRL, you may directly use the Node.js crl option instead). tlsCertificateFile has also been deprecated, please use tlsCertificateKeyFile or pass the cert directly to the MongoClient constructor.

In addition to the common driver options, the Node.js driver also passes through Node.js TLS options provided on the MongoClient to Node.js' tls.connect API, which may be convenient to reuse with other Node.js APIs.

Node.js native option MongoDB driver option name legacy option name driver option type
ca tlsCAFile sslCA string
crl N/A sslCRL string
cert tlsCertificateKeyFile sslCert string
key tlsCertificateKeyFile sslKey string
passphrase tlsCertificateKeyFilePassword sslPass string
rejectUnauthorized tlsAllowInvalidCertificates sslValidate boolean

New includeResultMetadata option for findOneAnd... family of methods.

This option defaults to true, which will return a ModifyResult type. When set to false, which will
become the default in the next major release, it will return the modified document or null if nothing matched.
This applies to findOneAndDelete, findOneAndUpdate, findOneAndReplace.

// With a document { _id: 1, a: 1 } in the collection
await collection.findOneAndDelete({ a: 1 }, { includeResultMetadata: false }); // returns { _id: 1, a: 1 }
await collection.findOneAndDelete({ a: 2 }, { includeResultMetadata: false }); // returns null
await collection.findOneAndDelete({ a: 1 }, { includeResultMetadata: true }); // returns { ok: 1, lastErrorObject: { n: 1 }, value: { _id: 1, a: 1 }}

Support for change stream split events

When change stream documents exceed the max BSON size limit of 16MB, they can be split into multiple fragments in order to not error when sending events over the wire. In order to enable this functionality, the collection must be created with changeStreamPreAndPostImages enabled and the change stream itself must include an $changeStreamSplitLargeEvent aggregation stage. This feature requires a minimum server version of 7.0.0.

Example:

await db.createCollection('test', { changeStreamPreAndPostImages: { enabled: true }});
const collection = db.collection('test');
const changeStream = collection.watch([{ $changeStreamSplitLargeEvent: {} ], {
  fullDocumentBeforeChange: 'required'
});

for await (const change of changeStream) {
  console.log(change.splitEvent); // If changes over 16MB: { fragment: n, of: n }
}

Programmatic management of search indexes

This PR adds support for managing search indexes (creating, updating, deleting and listing indexes). The new methods are available on the Collection class.

const indexes = await collection.listSearchIndexes().toArray(); // produces an array of search indexes
await collection.createSearchIndex({ name: 'my-index', definition: < index definition > } ); 
await collection.updateSearchIndex('my-index', < new definition >);
await collection.dropSearchIndex('my-index');

BSON updated to v5.4.0

Take a look at the bson package's release notes!

Snappy loaded lazily

Unlike our other compression mechanisms snappy was loaded at the module level, meaning it would be optionally imported whether or not the driver was configured to use snappy compression. Snappy is now aligned with our other optional peer dependencies and is only loaded when enabled.

Zstd and Kerberos are now optional peer dependencies

This allows users who do not use these features to not have them installed. Users who do use these feature will now have them lazy loaded upon first use.

listDatabases nameOnly option bug fix

The listDatabases API exposes the nameOnly option which allows you to limit its output to only the names of the databases on a given mongoDB deployment:

db.admin().listDatabases({ nameOnly: true });
// [
//   { name: 'local' },
//   { name: 'movies' },
//   ...
// ]

Prior to this fix, the option was not being set properly on the command, so the output was always given in full.

Thanks to @redixhumayun for submitting this fix!

saslprep "is not a function" fix for bundled deployments

saslprep is an optional dependency used to perform Stringprep Profile for User Names and Passwords for SCRAM-SHA-256 authentication. The saslprep library breaks when it is bundled, causing the driver to throw TypeErrors.

This release includes a fix that prevents the driver throwing TypeErrors when attempting to use saslprep in bundled environments.

Cursor.map transform bug fixes

The cursor API provides the ability to apply a map function to each document in the cursor:

const cursor = collection.find({ name: 'john doe' }).map(({ name }) => name);
for await (const document of cursor) {
  console.error(document); // only prints the `name` field from each document
}

Cursor iteration properly catches errors thrown from the transform applied in Cursor.map

Starting in version 4.0 of the driver, if the transform function throws an error, there are certain scenarios where the driver does not correctly catch this error and an uncaught exception is thrown:

const cursor = collection.find({ name: 'john doe' }).map(() => {
  throw new Error('oh no! error here'); // 
});
await cursor.next(); // process crashes with uncaught error

This release adds logic to ensure that whenever we transform a cursor document, we handle any errors properly. Any errors thrown from a transform function are caught and returned to the user.

Cursor.hasNext no longer transforms documents if a transform has been applied to the cursor

Version 4.0 introduced a bug that would apply a transform function to documents in the cursor when the cursor was iterated using Cursor.hasNext(). When combined with Cursor.next(), this would result in transforming documents multiple times.

const cursor = collection.find({ name: 'john doe' }).map((document) => document.name);
while (await cursor.hasNext()) { // this transforms the first document in the cursor once
	const doc = await cursor.next(); // the second document in the cursor is transformed again
}

This release removes the transform logic from Cursor.hasNext, preventing cursor documents from being transformed twice when iterated using hasNext.

Features

Bug Fixes

  • NODE-4977: load snappy lazily (#3726) (865e658)
  • NODE-5102: listDatabases nameOnly setting is sent as NaN (#3742) (b97132e)
  • NODE-5289: prevent scram auth from throwing TypeError if saslprep is not a function (#3727) (e006347)
  • NODE-5374: do not apply cursor transform in Cursor.hasNext (#3746) (0668cd8)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v3.7.4

Published by baileympearson over 1 year ago

The MongoDB Node.js team is pleased to announce version 3.7.4 of the mongodb package!

Release Highlights

This release fixes a bug that throws a type error when SCRAM-SHA-256 is used with saslprep in a webpacked environment.

3.7.4 (2023-06-21)

Bug Fixes

  • NODE-3711: retry txn end on retryable write (#3047) (1595140)
  • NODE-5355: prevent error when saslprep is not a function (#3733) (152425a)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.6.0

Published by W-A-James over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.6.0 of the mongodb package!

Release Highlights

Node 20 support

The MongoDB Node.js Driver now supports Node.js 20! 🎉

runCursorCommand API

We have added the Db#runCursorCommand method which can be used to execute generic cursor commands. This API complements the generic Db#command method.

TypeScript support for new time series options

The driver now has TypeScript support for the bucketMaxSpanSeconds and bucketRoundingSeconds options which will be available in MongoDB 7.0. You can read more about these options here.

Features

  • NODE-5019: add runCursorCommand API (#3655) (4da926e)
  • NODE-5071: support additional time series options (#3667) (ccf555d)

Bug Fixes

  • NODE-5249: remove strict flag from create collection options (#3677) (be8faaf)
  • NODE-5296: construct error messages for AggregateErrors in Node16+ (#3682) (e03178e)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native -

Published by baileympearson over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.5.0 of the mongodb package!

Features

  • NODE-4720: Add log messages to CMAP spec (#3645) (b27f385)
  • NODE-5004: dont create or drop ecc collections (#3660) (2264fbb)

Bug Fixes

  • NODE-5260: AWS Lambda metadata detection logic is too permissive (#3663) (d74d3f9)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.4.0

Published by nbbeeken over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.4.0 of the mongodb package!

Release Highlights

ChangeStream.tryNext Typescript fix

We have corrected the tryNext method on ChangeStream to use the TChange schema generic instead of the untyped Document interface. This may increase strictness for existing usages but aligns with the rest of the methods on the change stream class to accurately reflect the type returned from the driver.

Deprecations

The db.command() API has a number of options deprecated that were incorrectly included in the typescript interface the method reportedly accepts. A majority of the options relate to fields that must be attached to the command directly: readConcern, writeConcern, and comment.

Additionally, the collStats helper has been deprecated in favor of using database aggregations to get the same result: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/

​​NOTE: This release includes some experimental features that are not yet ready for production use. As a reminder, anything marked experimental is not a part of the stable driver API and is subject to change without notice.

Features and Deprecations

  • NODE-5166: bump max wire version for 7.0 (#3659) (561229b)
  • NODE-4970: deprecate collStats collection helper (#3638) (325c4bc)
  • NODE-5207: deprecate unsupported runCommand options and add spec tests (#3643) (d6d76b4)

Bug Fixes

  • NODE-5213: ChangeStream.tryNext() should return TChange type (#3649) (3b58ca1)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v4.16.0

Published by W-A-James over 1 year ago

The MongoDB Node.js team is pleased to announce version 4.16.0 of the mongodb package!

Features

  • NODE-5159: add FaaS env information to client metadata (#3639) (e0b20f1)
  • NODE-5199: add alternative runtime detection to client metadata (#3647) (fba16ad)

Bug Fixes

  • NODE-5161: metadata duplication in handshake (#3628) (b790142)
  • NODE-5200: relax SRV record validation to account for a dot suffix (#3640) (4272c43)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.3.0

Published by W-A-James over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.3.0 of the mongodb package!

Features

  • NODE-4696: add FaaS env information to client metadata (#3626) (0424080)
  • NODE-4774: deprecate cursor forEach (#3622) (8d76a71)
  • NODE-4791: deprecate duplicate bulk methods (#3623) (2839e95)
  • NODE-4795: deprecate addUser helper (#3624) (53a0aae)
  • NODE-5188: add alternative runtime detection to client metadata (#3636) (2a26de3)
  • NODE-5189: deprecate tcp keepalive options (#3621) (cc7c75a)

Bug Fixes

  • NODE-5042: relax SRV record validation to account for a dot suffix (#3633) (ad15881)
  • NODE-5171: allow upsertedId to be null in UpdateResult (#3631) (4b5be21)
  • NODE-5201: prevent warning when default value for deprecation option is used (#3646) (e7f6e4e)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.2.0

Published by nbbeeken over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.2.0 of the mongodb package!

Release Highlights

This release includes driver support for automatically obtaining Azure credentials when using automatic client side encryption. You can find a tutorial for using Azure and automatic encryption here: Use Automatic Queryable Encryption with Azure

Additionally, we have a number of minor bug fixes listed below.

NOTE: This release includes some experimental features that are not yet ready for use. As a reminder, anything marked experimental is not a part of the stable driver API and is subject to change without notice.

Features

  • NODE-5077: automatic Azure kms credential refresh (#3599) (8e87e5c)

Bug Fixes

  • NODE-3998: metadata duplication in handshake (#3615) (6d894d6)
  • NODE-4518: error message with invalid authMechanism is provided (#3597) (1a16b7e)
  • NODE-4854: set timeout on write and reset on message (#3582) (4a7b5ec)
  • NODE-5106: prevent multiple mongo client connect()s from leaking topology (#3596) (eb836bb)
    • Thank you @clemclx for contributing this fix! 🎉
  • NODE-5126: find operations fail when passed an ObjectId as filter (#3604) (2647b61)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v4.15.0

Published by nbbeeken over 1 year ago

The MongoDB Node.js team is pleased to announce version 4.15.0 of the mongodb package!

Features

  • NODE-5054: add AssumeRoleWithWebIdentity support to 4x driver (#3566) (8a8c386)

Bug Fixes

  • NODE-5097: set timeout on write and reset on message (#3590) (2d3576b)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.1.0

Published by W-A-James over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.1.0 of the mongodb package!

Release Highlights

Support for JavaScript bigints in the driver

The driver now supports automatic serialization of JavaScript bigints to BSON.Longs. It also supports deserializing of BSON.Long values returned from the server to bigint values when the useBigInt64 flag is passed as true.

import { MongoClient } from 'mongodb';

(async () => {
  const client = new MongoClient('<YOUR CONNECTION STRING>');
  const db = client.db('test');
  const coll = db.collection('bigints');

  await coll.insertOne({ a: 10n }); // The driver automatically serializes bigints to BSON.Long before being sent to the server

  const docBigInt = await coll.findOne({ a: 10n }, { useBigInt64: true }); // Must provide the useBigInt64 flag to specify that bigints get returned
  console.log(docBigInt);
  // { _id: ObjectId(...), a: 10n }
  const doc = await coll.findOne({ a: 10n }); // Must provide the useBigInt64 flag to specify that bigints get returned
  console.log(doc);
  // { _id: ObjectId(...), a: 10 }
  await client.close();
})()

Features

  • NODE-3445: add support for AssumeRoleWithWebIdentity in aws authentication (#3556) (e8a30b1)
  • NODE-4877: Add support for useBigInt64 (#3519) (917668c)
  • NODE-5050: support GCP automatic credential fetch for CSFLE (#3574) (722a4a6)

Bug Fixes

  • NODE-5044: Write Concern 0 Must Not Affect Read Operations (#3541) (#3575) (10146a4)
  • NODE-5052: prevent cursor and changestream close logic from running more than once (#3562) (71d0d79)
  • NODE-5064: consolidate connection cleanup logic and ensure socket is always closed (#3572) (e544d88)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v4.14.0

Published by nbbeeken over 1 year ago

The MongoDB Node.js team is pleased to announce version 4.14.0 of the mongodb package!

Deprecations

  • NODE-4992: Deprecate methods and options that reference legacy logger (#3532) (6c94b4a)

Bug Fixes

  • NODE-4999: Write Concern 0 Must Not Affect Read Operations (#3541) (ddfc2b9)
  • NODE-5026: revert "ensure that MessageStream is destroyed when connections are destroyed" (#3551) (c4da623)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.0.1

Published by nbbeeken over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.0.1 of the mongodb package!

This release reverts a fix that unintentionally caused a leak of internal driver resources.

Bug Fixes

  • NODE-5027: revert "ensure that MessageStream is destroyed when connections are destroyed" (#3552) (2d178d0)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - v5.0.0

Published by baileympearson over 1 year ago

The MongoDB Node.js team is pleased to announce version 5.0.0 of the mongodb package!

Release Highlights

Node.js driver v5 emphazises the modernization of our API.

Farewell to Callbacks

Most notably, we have removed support for callbacks in favor of a Promise-only public API.
To ease the migration to a Promise-only approach when using the Node.js driver, callback support is available via the mongodb-legacy package. You can read more about this change in the Optional callback support migrated to mongodb-legacy section of the migration guide.

Dot Notation No Longer Enabled by Default

Version 4.3.0 of the Node.js driver introduced strict type checking on Filter queries that used dot notation. This functionality was enabled by default and proved to be a barrier for users upgrading to later versions of the Node.js v4.x driver. In order to ease the migration to v5.0.0, type strictness on queries that use dot notation has been removed from the CRUD API. The type checking capabilities are still available in an experimental type called StrictFilter. You can read more about this change in the Dot Notation TypeScript Support Removed By Default section of the migration guide.

BSON v5

This release also adopts all the changes in BSON v5.0.0 (see the release notes).
The driver now exports a BSON namespace that also has BSON.EJSON APIs available.
When working in projects where both the driver and bson are used, we recommend importing BSON types (ObjectId, Long, etc.) and BSON APIs from the driver instead of from BSON directly to ensure consistency when serializing and deserializing instances of the BSON types.

Other Notable Changes

@aws-sdk/credential-providers has now been moved to an optional peer dependency.
Consequently, in v5.0.0 or later versions of the driver, the AWS credential provider module must be installed manually to enable the use of the native AWS SDK for authentication.

Collection.insert, Collection.update, and Collection.remove methods have been removed in favor of their non-deprecated counterparts. You can read more about this and other changes in our Driver v5 Migration Guide.

⚠BREAKING CHANGES

  • NODE-4522: remove callback support (#3499)
  • NODE-4817: remove legacy logger (#3518)
  • NODE-4867: adopt BSON v5 (#3490)
  • NODE-4738: remove dot notation support by default (#3520)
  • NODE-4950: remove bson-ext import (#3523)
  • NODE-4756: ok 1 with write concern failure event changes (#3525)
  • NODE-4034: make internal bulk result private (#3515)
  • NODE-4751: drop support for client encryption < 2.3.0 (#3521)
  • NODE-4684: remove collection insert, update, remove methods (#3500)
  • NODE-4924: remove mapReduce collection helper (#3511)
  • NODE-4925: remove deprecated options and types (#3513)
  • NODE-3818: remove slaveOk options (#3503)
  • NODE-3695: remove lastop and optime from bulk result (#3504)
  • NODE-3489: remove cursor close options (#3505)
  • NODE-4598: close cursor on early loop break (#3502)
  • NODE-3482: remove unref (#3494)
  • NODE-4521: remove custom promise library support (#3498)
  • NODE-4898: aws credential providers now optional peerDependency (#3497)
  • NODE-4436: update minimum supported node version (#3496)
  • NODE-4899: support only snappy 7 or later (#3491)

Features

  • NODE-5016: compile ts with target es2020 (#3545) (def266a)
  • NODE-3482: remove unref (#3494) (556812f)
  • NODE-3489: remove cursor close options (#3505) (88c03a1)
  • NODE-3695: remove lastop and optime from bulk result (#3504) (8900d40)
  • NODE-3818: remove slaveOk options (#3503) (2e28009)
  • NODE-4034: make internal bulk result private (#3515) (ebac1f5)
  • NODE-4436: update minimum supported node version (#3496) (cca5362)
  • NODE-4509: send 1 with hello commands (#3508) (cc8ea1d)
  • NODE-4521: remove custom promise library support (#3498) (af36ebb)
  • NODE-4522: remove callback support (#3499) (52853ff)
  • NODE-4598: close cursor on early loop break (#3502) (30c0aee)
  • NODE-4684: remove collection insert, update, remove methods (#3500) (14427d1)
  • NODE-4738: remove dot notation support by default (#3520) (26145df)
  • NODE-4751: drop support for client encryption < 2.3.0 (#3521) (3dae6da)
  • NODE-4756: ok 1 with write concern failure event changes (#3525) (fee783c)
  • NODE-4767: Change abstract cursor return type (#3531) (410ef30)
  • NODE-4817: remove legacy logger (#3518) (28c7cdd)
  • NODE-4867: adopt BSON v5 (#3490) (b850868)
  • NODE-4898: aws credential providers now optional peerDependency (#3497) (b9e4c7c)
  • NODE-4899: support only snappy 7 or later (#3491) (21db1a9)
  • NODE-4924: remove mapReduce collection helper (#3511) (10d757a)
  • NODE-4925: remove deprecated options and types (#3513) (8f8ea45)
  • NODE-4950: remove bson-ext import (#3523) (1470115)

Documentation

We invite you to try the mongodb library and report any issues to the NODE project.

node-mongodb-native - v5.0.0-alpha.0

Published by nbbeeken over 1 year ago

🚧 Testing Build Only

This alpha build is intended for internal testing only. Adopt at your own risk.

Changes listed in HISTORY.md.

5.0.0-alpha.0 diff v4.13.0 (2023-01-23)

node-mongodb-native - v4.13.0

Published by nbbeeken almost 2 years ago

The MongoDB Node.js team is pleased to announce version 4.13.0 of the mongodb package!

Features

  • NODE-4691: interrupt in-flight operations on heartbeat failure (#3457) (e641bd4)

Bug Fixes

  • NODE-4447: disable causal consistency in implicit sessions (#3479) (6566fb5)
  • NODE-4834: ensure that MessageStream is destroyed when connections are destroyed (#3482) (8338bae)

Documentation

We invite you to try the mongodb driver immediately, and report any issues to the NODE project.

node-mongodb-native - v4.12.1

Published by baileympearson almost 2 years ago

The MongoDB Node.js team is pleased to announce version 4.12.1 of the mongodb package!

Release Highlights

This version includes a fix to a regression in our monitoring logic that could cause process crashing errors that was introduced in v4.12.0.

If you are using v4.12.0 of the Node driver, we strongly encourage you to upgrade.

Bug Fixes

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - 4.12.0

Published by baileympearson almost 2 years ago

The MongoDB Node.js team is pleased to announce version 4.12.0 of the mongodb package!

Release Highlights

ChangeStreams are now AsyncIterators

ChangeStreams are now async iterables and can be used anywhere that expects an async iterable. Notably, change streams can now be used in Javascript for-await loops:

const changeStream = collection.watch();
for await (const change of changeStream) {
  console.log(“Received change: “, change);
}

Some users may have been using change streams in for-await loops manually by using a for-await loop with the ChangeStream’s internal cursor. For example:

const changeStream = collection.watch();
for await (const change of changeStream.cursor) {
  console.log(“Received change: “, change);
}

The change stream cursor has no support for resumabilty and consequently the change stream will never attempt to resume on any errors. We strongly caution against using a change stream cursor as an async iterable and strongly recommend using the change stream directly.

Server Monitoring Fix When Monitoring Events are Skipped

Version 4.7.0 of the Node driver released an improvement to our server monitoring in FAAS environments by allowing the driver to skip monitoring events if there were more than one monitoring events in the queue when the monitoring code restarted. When skipping monitoring events that contained a topology change, the driver would incorrectly fail to update its view of the topology.

Version 4.12.0 fixes this issue by ensuring that the topology is always updated when monitoring events are processed.

Performance Improvements with Buffering

This release also modifies the data structures used internally in the driver to use linked lists in places where random access is not required and constant time insertion and deletion is beneficial.

External Contributions

Many thanks to @ImRodry for helping us fix the documentation for our deprecated callback overloads in this release!

Features

  • NODE-4683: make ChangeStream an async iterable (#3454) (df8d9a4)

Deprecations

Bug Fixes

  • NODE-4609: allow mapping to falsey non-null values in cursors (#3452) (1bf6ef1)
  • NODE-4735: fix change stream consecutive resumabilty (#3453) (89b27e9)
  • NODE-4753: remove erroneous deprecation of geoNear (#3465) (199dcaf)
  • NODE-4783: handle orphaned operation descriptions (#3463) (4c9b4d8)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.

node-mongodb-native - 4.11.0

Published by baileympearson about 2 years ago

The MongoDB Node.js team is pleased to announce version 4.11.0 of the mongodb package!

Release Highlights

Recursive Schema Support

Version 4.3.0 of the Node driver added Typescript support for dot notation into our Filter type but
in the process it broke support for recursive schemas. In 4.11.0, we now support mutually recursive schemas and
provide type safety on dot notation queries up to a depth of 8. Beyond a depth of 8, code still compiles
but is no longer type checked (it falls back to a type of any).

interface Author {
    name: string;
    bestBook: Book;
}

interface Book {
    title: string;
    author: Author;
}
 
let authors: Collection<Author>

// below a depth of 8, type checking is enforced
authors.findOne({ 'bestBook.author.bestBook.title': 25 }}) 
// ✅ expected compilation error is thrown: "title must be a string"

// at a depth greater than 8 code compiles but is not type checked (9 deep in this example)
authors.findOne({ 'bestBook.author.bestBook.author.bestBook.author.bestBook.author.name': 25 }) 
// ⛔️ perhaps unexpected, no compilation error is thrown because the key is too deeply nested

Note that our depth limit is a product of Typescript's recursive type limitations.

AWS Authentication

If the optional aws-sdk dependency is installed, the driver will now use the SDK to get credentials
from the environment. Because of this, if you have a shared AWS credentials or config file, then
those credentials will be used by default if AWS auth environment variables are not set. To override this
behavior, set AWS_SHARED_CREDENTIALS_FILE="" in your shell or set the
equivalent environment variable value in your script or application. Alternatively, you can create
an AWS profile specifically for your MongoDB credentials and set the AWS_PROFILE environment
variable to that profile name.

External Contributions

Many thanks to those who contributed to this release!

  • @ermik provided an extremely large schema to test compilation with, which made testing our new recursive schema support possible with large schemas straightforward.
  • @noahsilas for documentation improvements in change streams and fixing our Typescript types for read preferences.
  • @zendagin for adding Typescript support for hashed indexes.
  • @biniona-mongodb for fixing our parsing of TLS options.
  • @LinusU for removing support for server versions lower than our minimum supported server version and improving error messages for unacknowledged writes with hints.

Features

  • NODE-3651: add hashed index type (#3432) (f6b56a1)
  • NODE-3875: support recursive schema types (#3433) (26bce4a)
  • NODE-4503: throw original error when server attaches NoWritesPerformed label (#3441) (a7dab96)
  • NODE-4650: handle handshake errors with SDAM (#3426) (cbe7533)
  • NODE-4721: add aws-sdk as optional dependency (#3446) (b879cb5)

Bug Fixes

  • NODE-3712,NODE-4546: electionId should be ordered before setVersion (#3174) (ca51fec)
  • NODE-3921: error on invalid TLS option combinations (#3405) (1a550df)
  • NODE-4186: accept ReadPreferenceLike in TransactionOptions type (#3425) (dc62bcb)
  • NODE-4475: make interrupted message more specific (#3437) (5f37cb6)
  • NODE-4608: prevent parallel monitor checks (#3404) (78bcfe4)
  • NODE-4647: improve error message (#3409) (0d3c02e)
  • NODE-4649: use SDAM handling for errors from min pool size population (#3424) (ef3b55d)

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.