Abhishek Sinha
Abhishek Sinha

Reputation: 113

Upgrade MongoDB Driver in Meteor 1.7.0.4

The default MongoDB driver version is 3.0.7 in Meteor 1.7.0.x

I need to use MongoDB driver version 3.1 since retryable writes has been fixed in 3.1 for multiple document updates (https://jira.mongodb.org/browse/NODE-1513)

How can I use driver version 3.1 with Meteor 1.7.0.x?

Upvotes: 11

Views: 715

Answers (1)

Jankapunkt
Jankapunkt

Reputation: 8423

The following is a workaround guide and should not be used in production apps!

Please not, that the last mongodb driver version, that is tagged as stable, is still 3.0.11 (2018/09). You should therefore assume, that MDG will not update the mongo driver until a newer version has been declared as stable.

Using any of the latest versions can lead to unknown / unexpected behavior, especially in production environments. Continue at your own risk.

Proceeding

  • Create a packages folder in your project directory
$ cd ~/path/to/your-project
$ mkdir -p packages
  • Clone or download meteor from Github (to ~/path/to/meteor).

  • Copy the core package from meteor to your packages folder

$ cd ~/path/to/meteor/packages/
$ cp -r npm-mongo ~/path/to/your-project/packages/
  • Edit the file package.js to the following latest release (currently 3.1.4):
// This has been moved out of the `mongo` package so it can be used by the tool
// via isopacket, without having to also load ddp-server.

Package.describe({
  summary: "Wrapper around the mongo npm package",
  version: "3.1.4",
  documentation: null
});

Npm.depends({
  mongodb: "3.1.4"
});

Package.onUse(function (api) {
  api.addFiles("wrapper.js", "server");
  api.export([
    "NpmModuleMongodb",
    "NpmModuleMongodbVersion",
  ], "server");
});
  • Run your app, cross your fingers.

Alternative step

  • Instead of downloading the whole Meteor project from source, you can just create a new folder named npm-mongo in packages/ and the reproduce the files from here, then edit package.js according to the guide above.

Upvotes: 0

Related Questions