CloudAnt: 返回仅匹配关键字数组的最后一个文档。

huangapple go评论48阅读模式
英文:

CloudAnt: return only the last document matching an array of keys

问题

我有数据库中的文档,其键值分别为"a","b","c"等。

现在我想获取多个键的最后一个匹配值,比如keys:["a", "c"],只返回"c"的文档。

在CloudAnt/CouchDB中是否有有效的方法来实现这个目标?我更倾向于只检索最后一个匹配项,而不是全部。我是否必须使用索引/选择器来实现这一点?

英文:

Say I have documents in my database with key values "a","b","c", etc.

Now I want to fetch the last matching value of multiple keys, such as keys:["a", "c"], returning the doc for "c" only.

Is there an efficient way to do this in CloudAnt/CouchDB? I'd prefer not to retrieve all matches, just the last. Do I have to use index/selector for this?

答案1

得分: 0

我最终执行了一个多键请求到现有视图,然后在客户端中减少了结果。我想我可以通过在原始视图中使用一个“reduce”函数来完成这个操作,这将减轻响应体积。

英文:

I wound up doing a multikey request to an existing view, then reducing the result in the client. I suppose I could do this via a 'reduce' function in the original view, which would lighten the response body.

huangapple
  • 本文由 发表于 2023年2月19日 07:02:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75496916.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定