Couchnode Upsert Response

时间:2015-07-28 07:31:19

标签: couchbase couchnode

我是沙发基地和couchnode的新手。考虑couchnode Documentation, upsert回调函数只返回err和CAS。我想获得更新或插入的对象作为响应。我怎么能这样做?

以下是upsert函数的文档详细信息。

upsert(元组,[选项,]回调)→Bucket

  • 元组:元组(带键和对应值的对象)
  • 选项:对象

    • cas:要检查的CAS值。如果服务器上的密钥包含
      不同的CAS值,操作将失败。请注意,如果这个 选项未定义,不执行比较。有关详细信息 传递每个键的CAS令牌,检查每个键选项。

    • 到期(默认为0):密钥的到期时间。如果它等于 零,该项目永远不会过期。您也可以使用Unix时间戳或 从当前时间开始的几秒钟,但在后者 例如,秒数不得超过2592000(30天).persist_to

    • (默认为0):确保此操作持久保存到这么多节点。
    • replicate_to(默认值为0):确保将此操作复制到此操作 很多节点。
  • 回调(错误,cas)
    • cas:包含密钥和相应CAS令牌的对象。

1 个答案:

答案 0 :(得分:1)

If the upsert operation is successful, the upserted object is the exact same value you passed to upsert in the first place. There is no point to duplicating this information.

If your callback is inside a closure, you can always reference the object you passed to upsert.