mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
chore: migration guide updated to 2.8
This commit is contained in:
@@ -36,33 +36,10 @@ Here are the newly added methods (you can see this description and the code [her
|
||||
```js
|
||||
for await (const document of collection.find(query, options)) /* ... */
|
||||
```
|
||||
**A few internal methods are now async.**
|
||||
|
||||
- These are: `MongoConnection` (constructor), `MongoInternals.RemoteCollectionDriver` (constructor), `MongoInternals.defaultRemoteCollectionDriver`, `OplogHandle` (constructor).
|
||||
|
||||
Adding these async counterparts allows gradual migration, as both versions will coexist for the time being. At the moment, all async methods are calling sync one directly, so all hooks and wrappers should work as expected.
|
||||
|
||||
<h3 id="should-i-update">Can I update to this version without changing my app?</h3>
|
||||
|
||||
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 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() {
|
||||
return await MongoInternals.RemoteCollectionDriver(/.../)
|
||||
}
|
||||
```
|
||||
- Use `.await()`, like so:
|
||||
```js
|
||||
const Connection = new MongoInternals.RemoteCollectionDriver(/.../).await();
|
||||
```
|
||||
|
||||
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.
|
||||
Yes. You can update to this version without changing your app.
|
||||
|
||||
<h2 id="older-versions">Migrating from a version older than 2.8?</h2>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user