我正在尝试将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 / [database] / _design / client / _view / docView { “偏移”:0, “TOTAL_ROWS”:0, “行”:[]}
感谢您的帮助:)
Mat2014 _
答案 0 :(得分:1)
现在最好的举措是升级到beta2:http://mobile.couchbase.com
这是最小化值的最佳做法,因此可能是emit(type.toString(),null)