New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mongodb driver to v3 #268

gustawdaniel opened this Issue Feb 15, 2018 · 7 comments


None yet
7 participants

gustawdaniel commented Feb 15, 2018

What could we do?

I propose to update mongodb: "2.2.33" to mongodb: "3.0.2" in packages/npm-mongo/package.js.


I wanted to use The filtered positional operator described in docs of mongodb on this page:

It works only for newest mongodb driver. Article about this in under link:

In this article there is written:

Using array filters with Node.js requires versions >= 3.0.0 of the MongoDB Node.js driver or >= 5.0.0 of mongoose in addition to v3.6 of the MongoDB server. Earlier versions of the MongoDB (2.x) and mongoose (4.x) do not support array filters.

Overview of the suggested solution

Simple change of version is not enough. @hwillson described this problem in this closed pull request:


I do not know details mentioned by him, but I am interested in any help.


This comment has been minimized.


klaussner commented Feb 15, 2018

Here's a summary of the required changes I found while going through the node-mongodb-native document:


MongoClient.connect passes the client instead of a database object to the callback function. This means that the driver doesn't create a Db instance from the database URL (e.g., mongodb://localhost:3001/meteor) anymore, so we have to create the Db instance in the callback:

function (err, client) {
  // ...
  const db = client.db("meteor");
  if (db.server.config.isMasterDoc) {
  // ...

Of course, the database name isn't always meteor, so we have to either parse the URL ourselves or use the (undocumented) client.s.options.dbName property to get the database name.

Removed functions

  • must be used instead of Cursor.prototype.nextObject (here).
  • MongoClient.prototype.close must be used instead of Db.prototype.close (here).

Renamed option


This comment has been minimized.

benan789 commented May 9, 2018

Using arrayFilters is working with rawCollection but not through meteor. Will this be added soon? I'm on 1.7-rc.3.


This comment has been minimized.

dobesv commented May 14, 2018

BTW I believe if you call client.db() with no parameter it'll use the dbName from the connection URL.


This comment has been minimized.


klaussner commented May 15, 2018

@dobesv This feature was added to node-mongodb-native shortly after I created the first pull request (meteor/meteor#9790). I changed the constructor to use client.db() in meteor/meteor#9831. 🙂


This comment has been minimized.


klaussner commented Jul 7, 2018

The driver has been updated in Meteor 1.7.


This comment has been minimized.

lamalex commented Sep 3, 2018

On Meteor and

    { $and: c.q },
    { $inc: { [identifier]: nutrient.value } },
    { arrayFilters: [ { 't.providerData.internalID': nutrient.providerData.internalID } ] }

fails whereas

    { $and: c.q },
    { $inc: { [identifier]: nutrient.value } },
    { arrayFilters: [ { 't.providerData.internalID': nutrient.providerData.internalID } ] }



This comment has been minimized.


mitar commented Sep 3, 2018

There is no third argument to update in Meteor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment