我正在尝试将 javascripte 视图(phonegap 项目)移动到本机视图(android),但 Mapper 函数不适用于 Couchbase Lite [beta 1],并且无法创建视图。
代码:
private int startCBLListener(int suggestedListenPort) throws IOException,
CouchbaseLiteException {
Manager manager = startCBLite();
dbLite=startDatabase(manager, DATABASE_NAME);
com.couchbase.lite.View viewItems = dbLite.getView(String.format("%s/%s",
"client",
"docView"));
viewItems.setMap(new Mapper() {
@Override
public void map(Map<String, Object> document, Emitter emitter) {
Object type = document.get("type");
if (type.toString()=="CLIE") {
emitter.emit(type.toString(), document);
}
}
}, "1.1");
LiteListener listener = new LiteListener(manager, suggestedListenPort);
int port = listener.getListenPort();
Thread thread = new Thread(listener);
thread.start();
return port;
}
对 CouchDB 服务器的 GET 请求给出以下结果: http://localhost:5984/[database]/_design/client {"status" : 404}
http://localhost:5984/[数据库]/_design/client/_view/docView {"offset":0,"total_rows":0,"rows":[]}
谢谢你的帮助 :)
垫子2014_