The official MongoDB Node.js driver
APACHE-2.0 License
Bot releases are hidden (Show)
Published by baileympearson over 1 year ago
The MongoDB Node.js team is pleased to announce version 3.7.4 of the mongodb
package!
This release fixes a bug that throws a type error when SCRAM-SHA-256 is used with saslprep in a webpacked environment.
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
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!
The MongoDB Node.js Driver now supports Node.js 20! 🎉
runCursorCommand
APIWe have added the Db#runCursorCommand
method which can be used to execute generic cursor commands. This API complements the generic Db#command
method.
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.
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
The MongoDB Node.js team is pleased to announce version 5.5.0 of the mongodb
package!
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
Published by nbbeeken over 1 year ago
The MongoDB Node.js team is pleased to announce version 5.4.0 of the mongodb
package!
ChangeStream.tryNext
Typescript fixWe 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.
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.
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
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!
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
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!
upsertedId
to be null in UpdateResult
(#3631) (4b5be21)We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
Published by nbbeeken over 1 year ago
The MongoDB Node.js team is pleased to announce version 5.2.0 of the mongodb package!
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.
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Published by nbbeeken over 1 year ago
The MongoDB Node.js team is pleased to announce version 4.15.0 of the mongodb package!
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
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!
bigint
s in the driverThe driver now supports automatic serialization of JavaScript bigint
s to BSON.Long
s. 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();
})()
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Published by nbbeeken over 1 year ago
The MongoDB Node.js team is pleased to announce version 4.14.0 of the mongodb package!
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
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.
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Published by baileympearson over 1 year ago
The MongoDB Node.js team is pleased to announce version 5.0.0 of the mongodb
package!
Node.js driver v5 emphazises the modernization of our API.
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.
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.
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.
@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.
We invite you to try the mongodb
library and report any issues to the NODE project.
Published by nbbeeken over 1 year ago
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)
Published by nbbeeken almost 2 years ago
The MongoDB Node.js team is pleased to announce version 4.13.0 of the mongodb package!
We invite you to try the mongodb driver immediately, and report any issues to the NODE project.
Published by baileympearson almost 2 years ago
The MongoDB Node.js team is pleased to announce version 4.12.1 of the mongodb package!
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.
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
Published by baileympearson almost 2 years ago
The MongoDB Node.js team is pleased to announce version 4.12.0 of the mongodb package!
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.
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.
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.
Many thanks to @ImRodry for helping us fix the documentation for our deprecated callback overloads in this release!
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.
Published by baileympearson about 2 years ago
The MongoDB Node.js team is pleased to announce version 4.11.0 of the mongodb package!
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.
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.
Many thanks to those who contributed to this release!
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Published by nbbeeken about 2 years ago
The MongoDB Node.js team is pleased to announce version 4.10.0 of the mongodb package!
Looking to improve our API's consistency and handling of errors we are planning to remove callback support in the next major release of the driver. Today marks the notice of their removal. Migrating to a promise only API allows us to offer uniform error handling and better native support for automatic promise construction. In this release you will notice deprecation warnings in doc comments for all our callback overloads and if you are working in VSCode you should notice strikethroughs on these APIs. We encourage you to migrate to promises where possible:
async
/await
syntax can yield the best experience with promise usage.require('util').callbackify(() => collection.findOne())(callback)
collection.findOne().then(res => callback(null, res), err => callback(err))
While the 4.10.0 version only deprecates our support of callbacks, there will be a major version that removes the support altogether. In order to keep using callbacks after v5 is released, we recommend migrating your driver version to mongodb-legacy (github link). This package wraps every single async API our driver offers and is designed to provide the exact behavior of the MongoDB 4.10.0 release (both callbacks and promises are supported). Any new features added to MongoDB will be automatically inherited but will only support promises. This package is fully tested against our current suite and adoption should be confined to changing an import require('mongodb')
-> require('mongodb-legacy')
. If this package is useful to you and your use case we encourage you to adopt it before v5 to ensure it continues to work as expected.
Read more about it on the package's readme here:
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Published by durran about 2 years ago
The MongoDB Node.js team is pleased to announce version 4.9.1 of the mongodb package!
This is a bug fix release as noted below.
Published by nbbeeken about 2 years ago
The MongoDB Node.js team is pleased to announce version 4.9.0 of the mongodb package!
We have corrected an inconsistency with our writeConcern options in the type definitions where the MongoClient alleged to not support "writeConcern" as an option. In fact, it did support it at run time and now the types correctly reflect that, along with the corresponding deprecations we made to the nested writeConcern config settings.
Our index specification handling had a few peculiar edge cases that we have detailed below, we believe these are unlikely to affect a vast majority of users as the type definitions would have likely reported an error with the impacted usage. As a feature, the typescript definitions now support a javascript Map as a valid input for an index specification.
As per usual this release brings in the latest BSON release (v4.7.0) which added automatic UUID support. You can read more about that in the BSON release notes here!
Special thanks to the folks who contributed to this release!
oplogReplay
flag support fixoplogReplay
option as deprecated (#3337) (6c69b7d)We invite you to try the mongodb library immediately, and report any issues to the NODE project.