Reputation: 11
I am trying to move javascripte views (phonegap project) to native views (android) but the Mapper function doesn't works with a Couchbase Lite [beta 1] , and view cannot be created.
Code:
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;
}
A GET request to the CouchDB server gives the following results: http://localhost:5984/[database]/_design/client {"status" : 404}
http://localhost:5984/[database]/_design/client/_view/docView {"offset":0,"total_rows":0,"rows":[]}
Thanks for any help :)
Mat2014_
Upvotes: 1
Views: 258
Reputation: 1034
The best move now is to upgrade to beta2 available here: http://mobile.couchbase.com
It's a best practice to minimize the value, so maybe emit(type.toString(), null)
Upvotes: 1