guide/source/2.6-migration.md
Most of the new features in Meteor 2.6 are either applied directly behind the scenes (in a backwards compatible manner) or are opt-in. For a complete breakdown of the changes, please refer to the changelog.
The above being said, there are a few items that you should implement to have easier time in the future.
<h3 id="launch-screens-ios">Cordova - Launch Screens for iOS</h3>You are now able to use dark theme specific splash screens for both iOS and Android by passing an object {src: 'light-image-src-here.png', srcDarkMode: 'dark-mode-src-here.png'} to the corresponding key in App.launchScreens
Legacy launch screens keys for iOS on App.launchScreens are now deprecated in favor of new storyboard compliant keys PR #11797. This will drop the following keys we have: ['iphone5','iphone6','iphone6p_portrait','iphone6p_landscape','iphoneX_portrait','iphoneX_landscape','ipad_portrait_2x','ipad_landscape_2x','iphone','iphone_2x','ipad_portrait','ipad_landscape']
To migrate replace the deprecated keys ['iphone5','iphone6','iphone6p_portrait','iphone6p_landscape','iphoneX_portrait','iphoneX_landscape','ipad_portrait_2x','ipad_landscape_2x','iphone','iphone_2x','ipad_portrait','ipad_landscape'] with the
corresponding new key: ['ios_universal','ios_universal_3x','Default@2x~universal~comany','Default@2x~universal~comcom','Default@3x~universal~anycom','Default@3x~universal~comany','Default@2x~iphone~anyany','Default@2x~iphone~comany','Default@2x~iphone~comcom','Default@3x~iphone~anyany','Default@3x~iphone~anycom','Default@3x~iphone~comany','Default@2x~ipad~anyany','Default@2x~ipad~comany']
and adapt necessary splash images to the new dimensions asked by Apple. You can get more info here.
Meteor before 2.6 was supporting MongoDB Server 4.x, starting from this version we've upgraded to MongoDB Node.js driver from version 3.6 to 4.3.1 which supports MongoDB Server 5.x.
This change was necessary at the time of writing this guide (January 2022) as MongoDB Atlas is going to migrate automatically all the clusters in the plans Atlas M0 (Free Cluster), M2, and M5 to MongoDB 5.0 in February 2022, but this change would be necessary anyway as this is now the latest version of MongoDB Server. The migration in the M0, M2 and M5 is just a sign from MongoDB that they believe MongoDB 5.0 should be the version used by everybody as soon as possible.
If you are running on MongoDB Atlas and in one of these plans you have to run Meteor 2.6 in order to connect and interact with your MongoDB properly as your MongoDB is going to be upgraded to 5.0 in February. If you are not running at these plans, you can continue to use your MongoDB at previous versions and you can use previous versions of Meteor still without any problems.
An important note is that we have migrated everything supported by Meteor to be compatible with MongoDB 5.x and also MongoDB Node.js Driver 4.x but this doesn't include, as you should expect, what you do in your code or package using rawCollection. rawCollection is a way for Meteor to provide you the freedom to interact with MongoDB driver but that also comes with the responsibility to keep your code up-to-date with the version of the driver used by Meteor.
That said, we encourage everybody to run the latest version of Meteor as soon as possible as you can benefit from a new MongoDB driver and also other features that we are always adding to Meteor.
This version of Meteor is also compatible with previous version of MongoDB server, so you can continue using the latest Meteor without any issues even if you are not running MongoDB 5.x yet. You can check here which versions of MongoDB server the Node.js driver in the version 4.3.0 supports and as a consequence these are the versions of MongoDB server supported by Meteor 2.6 as well. In short, Meteor 2.6 supports these versions of MongoDB server: 5.1, 5.0, 4.4, 4.2, 4.0, 3.6.
If you are using Embedded MongoDB in your local environment you should run meteor reset in order to have your database working properly after this upgrade. meteor reset is going to remove all the data in your local database.
If you depend on any method inside the rawCollection() object, you have to review every call with the new driver API here. Also make sure you check all the changes made to the driver here and here.
You can check an example applied to the "aggregate" function, which had changes to its API. The collection.rawCollection().aggregate() function doesn't expect a callback any more like in older versions, and aggregate().toArray() now returns a promise. For this specific case, we have written the fix in this PR.
If you are a user looking for errors that are showing in a custom package, please open an issue in the package owner repository so the maintainer can make the due changes.
applySkipLimit option for count() on find cursors is no longer supported. By default, this option will always be true. So, for example, let's say you have a collection with 50 documents and execute a find with a limit of 25:
const cursor = collection.find({}, { limit: 25 });
When you call cursor.fetch(), the result will be 25 documents, and cursor.count() will be 25. Whereas, in the previous version, cursor.count() would result in 50, in this case, and you would need to provide the option applySkipLimit to get the result 25.
Now, you'll need to create a new cursor, but this time not providing a limit, in order to get the number of all documents in your collection:
const cursorWithLimit = collection.find({}, { limit: 25 });
const cursorWithNoLimit = collection.find({});
// cursorWithLimit.fetch() => returns 25 documents
// cursorWithNoLimit.count() => returns 50
Remember that a find is a wrapper for the query, so creating two or more cursors in a row is totally fine and not slower at all.
Here is a list of the changes that we have made to Meteor core packages in order to make it compatible with MongoDB Node.js Driver 4.3.x, most of them are not going to affect you but we recommend that you test your application well before upgrading to the latest version of Meteor as we have made many changes on how Meteor interact with MongoDB.
It's worth mentioning that if you are using the built-in MongoDB that Meteor provides to run your app locally, you need to perform a meteor reset on your app to be able to use the version 2.6.
Below we describe a few common cases in this migration:
If you are not changing your MongoDB server version you don't need to change anything in your code, even if you are using rawCollection results, but as we did many changes on how Meteor interact with MongoDB in order to be compatible with the new driver we recommend that you test your application carefully before releasing to production with this Meteor version.
We've made many tests in real applications and also in our automatic tests suite, we believe we've fixed all the issues that we found along the way but Meteor interaction with MongoDB is so broad and open that maybe you have different use cases that could lead to different issues.
Again, we are not aware of any issues that were introduced by these changes, but it's important that you check your app behavior, especially if you have places where you believe you are not using MongoDB in a traditional way.
As we have made many changes to Meteor core packages in this version we recommend the following steps to migrate:
We are not aware of any issues that were introduced by the necessary changes to support MongoDB, but it's important that you check your app behavior, especially if you have places where you believe you are not using MongoDB in a traditional way.
For example, the MongoDB Oplog suffered a lot of changes, and we had to create a conversor to keep our oplog tail understanding the changes coming from the oplog, so if you have complex features and queries that depend on oplog (Meteor real-time diff system), you should review if your app is working properly especially in this part.
As MongoDB also removed a few deprecated methods that were used by Meteor we recommend testing all important operations of your application.
<h2 id="older-versions">Migrating from a version older than 2.5?</h2>If you're migrating from a version of Meteor older than Meteor 2.5, there may be important considerations not listed in this guide (which specifically covers 2.4 to 2.5). Please review the older migration guides for details: