CouchDB - Querying array key value for first key element only

后端 未结 1 673
执念已碎
执念已碎 2021-02-14 07:55

I have a couchdb view set up using an array key value, in the format:

[articleId, -timestamp]

I want to query for all entries with the same art

相关标签:
1条回答
  • 2021-02-14 08:23

    First, as a comment pointed out, there is indeed a special value {} that is ordered after any value, so your query becomes:

    startkey=["target ID"]&endkey=["target ID",{}]
    

    This is as equivalent to a wildcard match.

    As a side note, there is no need to reverse the ordering in the map function by emitting a negative timestamp, you can reverse the order as an option to the view invocation (your start and end key will be swapped).

    startkey=["target ID",{}]&endkey=["target ID"]&descending=true
    
    0 讨论(0)
提交回复
热议问题