我在CouchDB中有一堆MP3元数据.我想返回MP3元数据中的每张专辑,但不会重复.
典型的文档如下所示:
{ "_id": "005e16a055ba78589695c583fbcdf7e26064df98","_rev": "2-87aa12c52ee0a406084b09eca6116804","name": "Fifty-Fifty Clown","number": 15,"artist": "Cocteau Twins","bitrate": 320,"album": "Stars and Topsoil: A Collection (1982-1990)","path": "Cocteau Twins/Stars and Topsoil: A Collection (1982-1990)/15 - Fifty-Fifty Clown.mp3","year": 0,"genre": "Shoegaze" }
解决方法
我相信你的地图/减少将看起来像:
function map(doc) { emit(doc.album,null); } function reduce(key,values) { return null; }
请记住使用额外的参数group = true进行查询