PouchDB on Cloudant

巧了我就是萌 提交于 2019-12-10 22:25:43

问题


I am currently using PouchDB and I am making use of Cloudant to make my db in PouchDB to be on cloud.

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);

}

The result i got back is

Successfully posted a todo!


回答1:


Solution:

My error was because the host link I was using was incorrect. It should be in a format of http://username:password@mycluster.cloudant.com . 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.



来源:https://stackoverflow.com/questions/38725473/pouchdb-on-cloudant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!