Unable to retreive value from PouchDB-open source projects pouchdb/pouchdb
I DROPPED OUT OF A JAVA SCHOOL
Your allDocs query is running before you have completed inserting the data into PouchDB, due to the IndexedDB API all database queries are asynchronous (they likely would have to be anyway as it’s also a HTTP client).
new Pouch('idb://test', function(err, db) {
var doc = {
test : 'foo',
value : 'bar'
};
db.post(doc, function(err, data){
if (err) {
return console.error(err);
}
db.allDocs(function(err, data){
if (err) console.err(err)
else console.log(data)
});
});
});
… should work.