2
我正在嘗試在CouchDB 0.11中創建一個列表,用於響應某些html,我遇到了問題CouchDB設置了正確的標題,無論我嘗試什麼,我只是得到一個應用程序/ json響應頭。這是我的列表功能。從CouchDB列表中輸出html
function(head, req) {
var rows = [];
var row;
while(row = getRow()) {
rows.push(row);
}
rows.sort(function(a, b) {
return (Date.parse(a['value']['last_logtime']) - Date.parse(b['value']['last_logtime']));
});
provides("html", function() {
var content = "<html><head><title>foobar</title></head><body>";
for(var i in rows) {
content = content + rows[i]['value']['last_logtime']+"<br/>";
}
content = content + "</body></html>";
return content;
});
}
有什麼建議我做錯了什麼?
謝謝,好的,你已經提到,我與掙扎並沒有意識到。分享一個捕獲數據的常用方法,以便在每個提供內部調用時也是有用的,因爲您不需要繼續重複相同的任務;) – zanona 2011-09-23 06:14:24