Closed mizchi closed 9 years ago
You need to wait for the callback from the constructor. See the example in the Readme:
// Require minimongo
var minimongo = require("minimongo");
var IndexedDb = minimongo.IndexedDb;
// Create IndexedDb
db = new IndexedDb({namespace: "mydb"}, function() {
// Add a collection to the database
db.addCollection("animals", function() {
doc = { species: "dog", name: "Bingo" };
// Always use upsert for both inserts and modifies
db.animals.upsert(doc, function() {
// Success:
// Query dog (with no query options beyond a selector)
db.animals.findOne({ species:"dog" }, {}, function(res) {
console.log("Dog's name is: " + res.name);
});
});
});
}, function() { alert("some error!"); });
Or, better:
new IndexedDb({namespace: "mydb"}, function(db) {
// Do something with db, such as add a collection.
});
This log occurs at atom-shell envrironment but also occur at Chrome.
I tried 2 patterns but both failed. (sorry for coffeescript)
case 1
case 2
I added setTimeout before find so it works
I doubt minimongo lost correct callback of IndexedDb ready.