英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论