简体   繁体   English

Couchbase NodeJs SDK bucket.insert不返回值

[英]Couchbase NodeJs SDK bucket.insert not returning value

I am having a wired issue, when i do a insert / create new doc in my bucket it creates it successful and it returns the CAS value for new doc but if i want to access the actual result.value i get undefined. 我遇到了一个有线问题,当我在存储桶中执行插入/创建新文档时,它会成功创建它并返回新文档的CAS值,但是如果我要访问实际的result.value,则无法定义。 I can access result.cas. 我可以访问result.cas。 As i need to return the id which was created when creating the item in couchbase i am wondering how i can do that without making a separate call 因为我需要返回在沙发床中创建项目时创建的ID,所以我想知道如何在不进行单独调用的情况下做到这一点

var initialLead = function(doc){
bucket.insert('leads::' + uuidv4(), leadbase(doc), function(err, result) {
if (!err) {
  console.log("stored document successfully. Value is", result.value);
} else {
  console.error("Couldn't store document: %j", err);
}
});
}

In couchbase, the ID (aka key) is created by you, so you have it there to return. 在沙发床中,ID(又名密钥)是您创建的,因此可以在那里返回它。 The CAS is just an opaque value associated with that particular mutation. CAS只是与该特定突变相关的不透明值。

From you code example, your ID/key is: 'leads::' + uuidv4() 从您的代码示例中,您的ID /密钥是: 'leads::' + uuidv4()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM