如何在CouchDB中编写本机Erlang列表函数 [英] How to write Native Erlang list functions in CouchDB
本文介绍了如何在CouchDB中编写本机Erlang列表函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让一些人告诉我如何将简单的Javascript List函数转换为Erlang列表函数。这将是我开始的好点。
function(head,req){
var row,resp = {},数据= [];
if(head){
resp [total_rows] = head.total_rows;
}
while(row = getRow()){
data.push(row);
}
resp.rows = data;
返回JSON.stringify(resp);
}
提前谢谢
解决方案
你看过couchdb测试套件吗?
您将在utils / script / test / erlang_views.js找到erlang视图
测试套件中的代码经常帮助我,当我被卡住。
I am trying to write Erlang list functions in CouchDB, however, I am not familiar with the data types returned, and how to manipulate them accordingly. I would like some one to show me how to translate the simple Javascript List function below into an Erlang list function. That would be a good point for me to start.
function(head, req) {
var row,resp={},data=[];
if(head){
resp["total_rows"] = head.total_rows;
}
while(row = getRow()) {
data.push(row);
}
resp.rows = data;
return JSON.stringify(resp);
}
Thanks, in advance.
解决方案
Have you looked at the couchdb Test Suite. You'll find the erlang views at utils/script/test/erlang_views.js
The code in the test suite often helps me when I'm stuck.
这篇关于如何在CouchDB中编写本机Erlang列表函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文