【问题标题】:CouchDB Update Handler Won't Add CorrectlyCouchDB 更新处理程序不会正确添加
【发布时间】:2014-02-25 03:55:06
【问题描述】:

首先,我已阅读 CouchDB Document Update Handlers (in-place updates) 并采用了该问题答案中的代码。

我有一个更新处理程序,它接受一个查询字符串数量,并且应该将它添加到给定文档的 doc.count 中。它没有添加这两个数量,而是仅列出它们。例如。 5+5=55。 还将 parseInt() 添加到 doc.count 会产生错误消息:

{"error":"render_error","reason":"undefined response from update function"}

我的更新处理程序是:

"countPlus": "function(doc, req) {var amount1 = doc.count; var amount2 = parseInt(req.query.amount); doc.count = amount1 + amount2; return [doc, doc.count] ; }"

处理请求的js是:

if (count != null && count != NaN && count != 0) {
    var currentCounter = $.ajax({
    type: "POST",
    async: false,
    url: $(location).attr("href").replace("_show/action", "_update/countPlus") + "?amount=" + count,
    contentType : "application/json",         
    dataType: "json"
          });
var currentCountResponse = currentCounter.responseText;
        alert(currentCountResponse);

【问题讨论】:

    标签: couchdb handler


    【解决方案1】:

    您的回复似乎是一个整数。也许你应该尝试“字符串化”它。

    【讨论】:

      猜你喜欢
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多