pouchdb : 添加 key/value 到文件

pouchdb : add key/value to document

我正在使用 pouchDB,但我对它还很陌生。 我想将 key/value 添加到我的用户数据库中的文档中。 这是我的尝试:

this.addToExistingUser = function(docId,key,value) {
    usersDatabase.get(docId).then(function(doc) {
      return db.put({
        _id: docId,
        _rev: doc._rev,
        key: value
      });
    }).then(function(response) {
      alert("done eee");
    }).catch(function (err) {
      console.log("error from addToExistingUser:");
      console.log(JSON.stringify(err));
    });
}

其中 docId 是我定位的文档的 _id。 顺便问一下,我可以使用电子邮件字段指向我要定位的文档吗?

我收到这个错误:

{"status":404,"name":"not_found","message":"missing","error":true,"reason":"missing"}

谢谢

最后,我这样做了,它可以在文档中添加一个字段:

usersDatabase.get(docId).then(function(doc) {
          doc[key] = value;
          return usersDatabase.put(doc);
        }).then(function(response) {
        }).catch(function (err) {
        });