Irrelon / ForerunnerDB

A JavaScript database with mongo-like query language, data-binding support, runs in browsers and hybrid mobile apps as a client-side DB or on the server via Node.js!

Home Page:http://www.irrelon.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Multiple Databases - Breaking Change Since v1.3.36

Irrelon opened this issue · comments

In order to support multiple named databases Forerunner's instantiation has changed slightly. In previous versions you only had access to a single database that you instantiated via:

var db = new ForerunnerDB();

Now you have access to multiple databases via from the main forerunner instance but this requires that you change your instantiation code to:

var fdb = new ForerunnerDB();
var db = fdb.db('myDatabaseName');

Multiple database support is a key requirement that unfortunately requires we change the instantiation pattern as detailed above. Although this is a fundamental change to the way ForerunnerDB is instantiated we believe the impact to your projects will be minimal as it should only require you to update at most 2 lines of your project's code in order to "get it working" again.

Persistence Module and Multiple Databases

Please also note that while we have updated the instantiation to support multiple databases (to ensure that future projects are using the correct instantiation pattern), multiple database support is still a work in progress. This means that the persistence module still expects to be operating under a single database and will not save / load data based on the database name so persistence will load the same data for every database regardless of the DB name.

An update to the persistence module is coming to ensure multiple databases are supported. Other functionality should not be affected by the change to multiple DB support and should operate as expected. If you find any area of ForerunnerDB that is affected but not mentioned here, please reply to this issue and let us know so we can fix it ASAP!

Thanks!

commented

Maybe if there is only 1 database, load if by default?

@YuriSolovyov Multi-DB support in persistence module is pretty easy really. It's just a minor update around how the data is saved and loaded. With the addition of eager save / load mode (your issue #41) databases will also load their persistent data on first access.

commented

I was just thinking of how you can have some kind of backward compatibility here.

@YuriSolovyov Ahh I see. Yes I think the plan will be to detect any previously "unasigned" data and load it in to the first DB that gets requested, then on save it will be in the new multi-db format.

Technically since all ForerunnerDB projects have been single-db only up until this point it should be save to assume the saved data is for the first database being requested.

Persist module multi-db support now available in version 1.3.52

Since this is now quite a few versions ago, this announcement is now being closed.

Hmm... but the examples on the main page still use the old init procedure??
http://www.forerunnerdb.com/demo.html

@mojovski Corrected :)