Factory wrapper for SQLite plugin

@ronyrun: does the DB gets stored somewhere??

1 Like

the DB is stored within the the browser.
In ionic case it’s created as a SQLITE file in the root area.

@ronyrun By “ROOT” do you mean its created within the app or is it a visible file that can be accessed using tools like Mozilla Firefox SQLite plugin?

Link seems to be down, could you please reupload?

Thanks for the service, works great!

I would avoid to re-init the db all the time, if db is defined, use that instance

could you elaborate on this? thanks

Maybe I misunderstood the code above, anyway I would add a method to get the instance of the database if it is already defined. Since Angular modules are singletons, we just need to return it, no need to check if it exists already, as after calling init() it will always be.

self.getDatabase =  function(){

    return self.db;

}

that way you can use the db object in other factories using SqliteService.getDatabase()

Otherwise you have to place all your business logic in the same factory/file which will become huge for any medium/big size application.

I hope it is clear

If you need a functional working example of SQLite integration in Ionic, you may be interested to check out Quizionic App template in CodeCanyon here: http://codecanyon.net/user/studiomob/portfolio?ref=StudioMob

See my good example: https://github.com/jdnichollsc/Ionic-Starter-Template

Regards, Nicholls