ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

Way to switch database connections #204

Closed gimzani closed 3 years ago

gimzani commented 3 years ago

Consider this:

I have 2 iDB databases connected to jsStore. connection.initDb() will create them, but I need a way to switch between them.

I see in the documentation that is says that the connection can only handle 1 DB at a time - but I do NOT see any way to switch between them. Is there a way to "open" the database so that the connection is connected to the desired DB?

Something like: connection.openDb('my-db-name');

Thanks!

ujjwalguptaofficial commented 3 years ago

yes, there is api - openDb(dbName: string) which can be used to openDb. You cal also use initDb which will take dbschema as defined in documentation.

ujjwalguptaofficial commented 3 years ago

FYI - multiple database will be supported in version 4.

ujjwalguptaofficial commented 3 years ago

@gimzani jsstore v4 is launched. Now you can use multiple database with multiple connection.

var connection1 = new Connection();
var connection2 = new Connection();

connection1.initDb(dbSchema1);
connection2.initDb(dbSchema2);