在新的ForerunnerDB()命令之后清除现有的ForerunnerDB数据库

时间:2015-11-24 15:49:31

标签: forerunnerdb

无法让ForerunnerDB加载现有数据。浏览器刷新后,整个IndexedDB数据库在执行新的ForeRunnerDB()命令后从Chrome资源中消失。

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();
}

1 个答案:

答案 0 :(得分:2)

通过将函数传递给Collection.load()来解决问题:

videoCollection.load(function() {
    // Do something with data here
});