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

Newb Q: How do I know if the instance wasn't created before? #99

Open
GianlucaBobbio opened this issue Feb 26, 2016 · 2 comments
Open
Labels

Comments

@GianlucaBobbio
Copy link

Im on Ionic, I need a DB to work on, with and without connection. My Q is, I need 2 instances of localForage, so how do I put in angular.run() that? I tried

if(!$localForage.instance('WorkOrders')){
        $localForage.createInstance({
            name: 'WorkOrders'
        });
    }

    if(!$localForage.instance('Inspections')){
        $localForage.createInstance({
            name: 'Inspections'
        });
    }

But it's not working (its first time so localForage.instance('Inspections') doesn't exist, but crush instead returning null)

@maiskovich
Copy link

I was having the same problem and i solve it using "try" and "catch"

 try {
      this.articlesInstance=$localForage.instance('articles');
    }
    catch(err) {
      this.articlesInstance = $localForage.createInstance({
        name: 'articles'
      });
    }

I hope it helps you

@GianlucaBobbio
Copy link
Author

Thanks, good idea. I finally did on another way (old project, cant remember)

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

No branches or pull requests

3 participants