node-mongodb-native

The official MongoDB Node.js driver

APACHE-2.0 License

Downloads
25.2M
Stars
10K
Committers
461

Bot releases are hidden (Show)

node-mongodb-native -

Published by mbroadst almost 5 years ago

The MongoDB Node.js team is pleased to announce version 3.3.4 of the driver

Release Highlights

This release primary consists of improvements to the "unified topology". In particular, a regression with interaction between the connection pool and topology could result in servers which "go away" (due to network error, for example) would not return, resulting in a MongoTimeoutError.

Release Notes

node-mongodb-native -

Published by daprahamian about 5 years ago

The MongoDB Node.js team is pleased to announce version 3.3.0 of the driver

Release Highlights

Server Version 4.2 feature support

This latest release brings support for features in the newly released MongoDB v4.2:

  • Distributed Transactions
  • On-Demand Materialized Views with the $merge operator
  • Wildcard Indexes
  • Retryable Reads
  • MongoDB Query Language Enhancements.

SRV Polling for Sharded Clusters

The Driver has supported connecting to a cluster using an SRV record since version 3.0. Prior to now, we would only resolve the SRV record when initially connecting. This was fine for single replica sets, as the driver is able to discover new members added after initial connect from any member of a replica set. However, in a sharded deployment, individual mongos processes do not have an awareness of each other. This means that if the deployment changes in a shared cluster, the driver would have no way of knowing without disconnecting and connecting with a new client.

Starting in 3.3, if a driver connects to a sharded cluster with an SRV record, we will now periodically check that SRV record for any changes in the deployment, and update the client-side connections accordingly.

**NOTE: This feature is only available when starting a client with { useUnifiedTopology: true } **

Beta support for MongoDB Client-Side Encryption

The driver now has support for MongoDB Client-Side Encryption. This requires installing the mongodb-client-encryption npm package in your project.

Merged mongodb-core into node-mongodb-native

Up until this release, the mongodb driver has consisted of two components:

  • mongodb-core: The low-level engine of the driver.
  • node-mongodb-native: The API layer of the driver, published as mongodb

Over time, this separation has done more harm than good, and has led to increased development time for repairing bugs and implementing new features. Starting in the 3.3 release of mongodb, we have merged mongodb-core into node-mongodb-native, removing this barrier to development.

Release Notes

node-mongodb-native -

Published by mbroadst over 5 years ago

The MongoDB Node.js team is pleased to announce version 3.2.1 of the driver.

Due to a publishing snafu v3.2.1 was immediately published without a proper v3.2.0 release

The Topology class no longer uses a callback store, instead relying on a server selection loop for operation execution. This means failed operations will fail faster, with more accurate stack traces and specifics about the failure. It generally makes it much easier to reason about what the driver is doing each time an operation is executed.

You can enable it with the useUnifiedTopology feature flag passed to your MongoClient constructor, like so:

const client = MongoClient('mongodb://localhost:27017', { useUnifiedTopology: true });

This topology layer will replace the existing topologies in a breaking 4.x release later this year, so we strongly encourage our users to try it out as soon as possible.

A call to withTransaction begins a new transaction, executes the provided function, and then attempts to commit the transaction. The function passed to withTransaction must take a session parameter, and this session must be passed to all methods within the function. If some error is encountered, it will attempt to re-commit the transaction before ultimately failing back to the user after aborting the transaction.
NOTE: A mentioned, the passed in function MAY be retried multiple times, please keep this in mind when executing non-database operations within the function.

Here’s an example of it in action:

const client = new MongoClient();
await client.connect();

const session = client.startSession();

// NOTE: the `withTransaction` method only supports functions that return a `Promise`
try {
  await session.withTransaction(async function(session) {
     const coll = client.db('foo').collection('coll');
     await coll.insertOne({ a: 42 }, { session });
  });
} catch (err) {
  // transaction failed after attempted retry
  console.dir({ err });
}
client.connect().then(async function() {
  const collection = client.db(‘test’).collection(‘asyncIterators’);
  const cursor = collection.find();

  for await(const doc of cursor) {
    console.log(item);
  }
});
node-mongodb-native -

Published by christkv about 9 years ago

2.0.44 09-28-2015

  • Bug fixes for APM upconverting of legacy INSERT/UPDATE/REMOVE wire protocol messages.
  • NODE-562, fixed issue where a Replicaset MongoDB URI with a single seed and replSet name set would cause a single direct connection instead of topology discovery.
  • Updated mongodb-core to 1.2.14.
  • NODE-563 Introduced options.ignoreUndefined for db class and MongoClient db options, made serialize undefined to null default again but allowing for overrides on insert/update/delete operations.
  • Use handleCallback if result is an error for count queries. (Issue #1298, https://github.com/agclever)
  • Rewind cursor to correctly force reconnect on capped collections when first query comes back empty.
  • NODE-571 added code 59 to legacy server errors when SCRAM-SHA-1 mechanism fails.
  • NODE-572 Remove examples that use the second parameter to find().
node-mongodb-native -

Published by christkv about 9 years ago

  • Propagate timeout event correctly to db instances.
  • Application Monitoring API (APM) implemented.
  • NOT providing replSet name in MongoClient connection URI will force single server connection. Fixes issue where it was impossible to directly connect to a replicaset member server.
  • Updated mongodb-core to 1.2.12.
  • NODE-541 Initial Support "read committed" isolation level where "committed" means confimed by the voting majority of a replica set.
  • GridStore doesn't share readPreference setting from connection string. (Issue #1295, https://github.com/zhangyaoxing)
  • fixed forceServerObjectId calls (Issue #1292, https://github.com/d-mon-)
  • Pass promise library through to DB function (Issue #1294, https://github.com/RovingCodeMonkey)