2
我目前使用的是PouchDB,我正在利用Cloudant使PouchDB中的數據庫在雲上運行。PouchDB on Cloudant
我做了回調方法,它給了一個成功的回調,但是,我檢查我的Cloudant數據庫,有0個文件創建,但有8個更新序列。
我可以知道爲什麼嗎?這是我使用的一組代碼。
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);
}
結果我回來就是
Successfully posted a todo!
也許'http:// example.cloudant.com/example'不是正確的數據庫鏈接。我認爲你必須鏈接在你的賬戶中創建的數據庫。 – Hydro
@TheProHands在我的實際代碼中,我將其設置爲「http:// USERNAME.cloudant.com/DATABASE」,其中'USERNAME'是我的用戶名,'DATABASE'是我的數據庫的名稱。 – Alvin
@TheProHands我已經解決了這個問題,我發佈了我自己的解決方案。非常感謝你的幫助!非常感謝! – Alvin