2

Cannot get ForerunnerDB to load existing data. Upon browser refresh, entire IndexedDB database disappears from Chrome resources after executing new ForeRunnerDB() command.

var fdb = new ForerunnerDB();
// Existing database disappears from Chrome resources here

var db = fdb.db('VRC');
db.collection('videos').load();
var videoCollection = db.collection('videos');

if (!videoCollection.count()) {

    videoCollection.setData([
    {
        "_id": 1,
        "name": "Joe"
    },
    {
        "_id": 2,
        "name": "Susan"
    }]);

    // Yeah, I know this is redundant...
    videoCollection.save();
    db.save();
    ForerunnerDB.save();
}
mpan111
  • 41
  • 4

1 Answers1

2

Problem was solved by passing a function to Collection.load():

videoCollection.load(function() {
    // Do something with data here
});
mpan111
  • 41
  • 4
  • 1
    Sorry I only just saw this question... looks like you've got to the answer yourself anyway but the reason is that load() is an async call so if you try to access data immediately afterwards without waiting for the callback from ForerunnerDB you may not see the data. The callback is called once the load method has completed. – Rob Evans Jan 20 '16 at 20:21