【问题标题】:Bulk operation has failed in CouchbaseCouchbase 中的批量操作失败
【发布时间】:2014-11-03 08:05:43
【问题描述】:

我是 Couchbase 的新手。 我正在尝试从 Couchbase Server 3.0.1 上的 Couchbase Documents 使用 Node.js 进行一些基本操作。 当我尝试批量操作时,从 Couchbase 文档中获取的代码失败了。

有一个名为“test”的数据桶。并且bucket有2条记录,它们的doc号为1和2。如果我一个一个拿到文档,我就可以成功。

但以下代码返回错误,例如;

throw new TypeError('第一个参数需要是字符串或缓冲区。');

我的代码;

var couchbase = require("couchbase");
var cluster = new couchbase.Cluster('192.168.170.129:8091');
var bucket = cluster.openBucket('test');

// Bulk operation

bucket.get(['1', '2'], function(err, res) {

  if(err) {
    console.log("one or more operation failed", err);
    return;
  }

  console.log("success!", res);

});

已编辑:我使用的是 Couchbase Node.js 2.0

【问题讨论】:

  • 您使用的是哪个版本的 Couchbase Node.js SDK?
  • 我使用的是 Couchbase Node.js 2.0。

标签: node.js couchbase couchbase-lite couchnode


【解决方案1】:

从 Couchbase Node.js 2.0.0 API documentation 开始,get() 仅对单个键进行操作。

你要找的函数是getMulti():

bucket.getmulti(['1', '2'], function(err, res) {

  if(err) {
    console.log("one or more operation failed", err);
    return;
  }

  console.log("success!", res);

});

【讨论】:

    猜你喜欢
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-25
    • 1970-01-01
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多