- migration guide 2.7.4 review

This commit is contained in:
denihs
2022-07-22 13:43:24 -04:00
parent 7bfe25c426
commit 3ec1754ef1

View File

@@ -5,7 +5,7 @@ description: How to migrate your application to Meteor 2.7.4.
Meteor `2.7.4` introduce the new MongoDB Package Async API. For a complete breakdown of the changes, please refer to the [changelog](http://docs.meteor.com/changelog.html).
For this new async API, we have new methods like `findOneAsync`, which behaves exactly like the `findOne` method, but it now returns a promise that needs to be solved to get the data.
For this new async API, we have new methods like `findOneAsync`, which behaves exactly like the `findOne` method, but it now returns a promise that needs to be resolved to get the data.
<h3 id="why-like-this">Why this is important?</h3>
@@ -48,7 +48,7 @@ Yes and no.
If you're not using any constructor, like `MongoInternals.RemoteCollectionDriver`, then yes. Your app will run normally.
But if you're using a construction like that one, then an error be thrown because these are async now. In this case, you have two options:
But if you're using a construction like that one, then an error will be thrown because these are async now. In this case, you have two options:
- You can wrap the call in an async function, like so:
```js
async function Connection() {
@@ -60,7 +60,9 @@ But if you're using a construction like that one, then an error be thrown becaus
const Connection = new MongoInternals.RemoteCollectionDriver(/.../).await();
```
The last option is easier for a quick fix. Just bear in mind that the function `.await()` in working with Fibers, meaning that it'll be deprecated in the future.
The last option is easier for a quick fix. Just bear in mind that the function `.await()` is working with Fibers, meaning that it'll be deprecated in the future.
Also, remember to add the `ecmascript` package, otherwise the async won't work. The `ecmascript` package has the build plugin that compiles await and async to run within fibers.
<h2 id="older-versions">Migrating from a version older than 2.7.4?</h2>