Skip to content
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

Are asynchronous migrations possible? #211

Open
AS-Omar opened this issue Dec 15, 2021 · 1 comment
Open

Are asynchronous migrations possible? #211

AS-Omar opened this issue Dec 15, 2021 · 1 comment

Comments

@AS-Omar
Copy link

AS-Omar commented Dec 15, 2021

Is it possible to make a migration execute asynchronously? Would something like this actually respect the async and await statements?

import getAvailableDrives from '@/utils/get-available-drives'

const Store = require('electron-store')

const store = new Store({
  migrations: {
    '2.0.0': async store => {
      const availableDrives = await getAvailableDrives()

      const products = store.get('installedProducts', [])

      products.forEach(product => {
        product.installedOnDrive = availableDrives[1]
      })

      store.set('installedProducts', products)
    }
  }
})
@sindresorhus
Copy link
Owner

sindresorhus commented Dec 15, 2021

This is not possible as the electron-store is fully synchronous. However, you could use a package like make-synchronous yourself (we cannot use this package here by default as it does have some documented downsides).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants