_changes API不能在Couchbase Lite上使用过滤器和视图参数

_changes API not working with filter and view parameter on Couchbase Lite

本文关键字:过滤器 参数 视图 Lite API changes 不能 Couchbase      更新时间:2023-09-26

_changes 文档不清楚filterview参数,在Couchbase Lite中。我试图查询下面的url获取更改,如果一个文档与类型顺序被添加。

_changes?include_docs=true&feed=longpoll&since=0&filter=_view&view=orders%2Forder

这个filter=_view&view=orders%2Forder查询参数是问题所在,从上面删除相同的获取所有文档

在Couchbase Lite上使用上述方法会得到404,但在CouchDB上也是如此。回应:

{
    status: 404,
    error: "not_found"
}

这是我的_design/orders

{
     "_id": "_design/orders",
     "language": "javascript",
     "views": {
          "order": {
               "map": "function(doc) {if(doc.type && doc.type == 'order') {emit(doc.oID, doc);}}"
           }
      }
}

请分享一个语法或例子,如何通过设计文档和/或视图在_changes API得到一个过滤的输出。

每个发现这个的人,我认为答案可以像这样改变过滤器本身和查询字符串:

过滤器:

{
 "_id": "_design/orders",
 "language": "javascript",
 "filters": {
      "order": "function(doc) {if(doc.type && doc.type == 'order') {emit(doc.oID, doc);}}"
  }
}

和查询字符串:

_changes?include_docs=true&feed=longpoll&since=0&filter=orders/order