问题描述
我当前正在使用PouchDB,并且正在使用Cloudant将PouchDB中的数据库放置在云上。
I am currently using PouchDB and I am making use of Cloudant to make my db in PouchDB to be on cloud.
我做了回调方法,并给出了成功的回调,但是,我在Cloudant上检查了数据库,创建了0个文档,但是有8个更新序列。
I did callback method and it gave a success callback, however, I check my database on Cloudant, there's 0 doc created but there's 8 update seq.
我可以知道为什么吗?这是我使用的一组代码。
May I know why? This is my set of code I used.
function pouchdb() {
var db = new PouchDB("todos");
var remoteDB = new PouchDB("http://example.cloudant.com/example");
var todo = {
_id: "mittens1233",
title: "hello",
occupation: "kitten123"
};
db.put(todo, function callback(err, result) {
if (!err)
console.log('Successfully posted a todo!');
});
db.put(doc);
PouchDB.sync(db, remoteDB);
}
我回来的结果是
成功发布了待办事项!
推荐答案
解决方案:
我的错误是因为我使用的主机链接不正确。它的格式应为。我生成了一个API密钥,并将该密钥用作用户名,并将密码用作密码。然后它起作用了。我能够创建和查询文档。
My error was because the host link I was using was incorrect. It should be in a format of http://username:[email protected] . I generated an API key and used the key as username and password as password. Then it worked. I was able to create and query document.
这篇关于Cloudant上的PouchDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!