【发布时间】:2014-04-04 12:59:31
【问题描述】:
我现在正在尝试让 PouchDB 工作两天 - 一些简单的东西可以工作,有些则不行。
很难找出原因,但我终于设法找出了一个问题 - 是不是问题 随着 IndexDB 破坏数据库并再次创建 OR 承诺在 PouchDB 中实现,我不知道。
无论如何 - 下面的代码在 Firefox 中工作到最后,但在 Chorme 中只到达“正在创建数据库...”并且没有任何警告就停止(在调试器下永远不会到达“发布记录”)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script src="lib/pouchdb/dist/pouchdb-nightly.js"></script>
<script>
new PouchDB('test')
.then(function (db) {
console.log("Destroying database.. ");
return db.destroy()
})
.then(function () {
console.log("Creating database.. ");
return new PouchDB('test');
})
.then(function (db) {
console.log("Posting record.. ");
return db.post({name: 'name'});
})
.then(function(info){
console.log("Checking id of inserted record: " + info.id);
})
.catch(function (error) {
console.log(error.message);
});
</script>
</body>
</html>
任何解决方法?
我需要“销毁数据库->然后创建新的->然后做一些事情”的操作流程,每次都可以在每个浏览器中工作-我尝试使用承诺和回调-得到代码示例或 IndxedDB 错误 11 中的结果...
【问题讨论】:
-
这里没问题,在 Chrome 中创建和删除数据库。
标签: pouchdb