How do I do the SQL equivalent of “DISTINCT” in CouchDB?

前端 未结 2 1615
攒了一身酷
攒了一身酷 2020-12-09 18:38

I have a bunch of MP3 metadata in CouchDB. I want to return every album that is in the MP3 metadata, but no duplicates.

A typical document looks like this:



        
相关标签:
2条回答
  • 2020-12-09 19:00

    Have a look at View Cookbook for SQL Jockeys' Get Unique Values section.

    0 讨论(0)
  • 2020-12-09 19:02

    I believe your map/reduce would look something like:

    function map(doc) {
        emit(doc.album, null);
    }
    
    function reduce(key, values) {
        return null;
    }
    

    Remember to query with the extra parameter group=true

    0 讨论(0)
提交回复
热议问题