-
Notifications
You must be signed in to change notification settings - Fork 60
Creating inline views using Ektorp CouchDbRepositorySupport throws NullPointerException when compiling view #84
Comments
inline views is not something I've ever seen working with TouchDB-Android. That doesn't mean it can't work, just that you'll have to help figure out what is going wrong. I would recommend 2 things.
|
I tried creating the view manually using TDDatabase.getViewName(...) method. This means that the "all" view that I created didn't actually get saved to the db somehow. My code to create the view: db.getViewNamed("Badge/all").setMapReduceBlocks(new TDViewMapBlock() {
@Override
public void map(Map<String, Object> document, TDViewMapEmitBlock emitter) {
Object type = document.get("type");
Object id = document.get("_id");
Object groupId = document.get("groupId");
Object userId = document.get("userId");
if (type != null && type.equals("Badge")) {
emitter.emit(ComplexKey.of(groupId, userId), id);
}
}
}, null, "1.0"); If I use the inline view, the exception stack trace is:
|
That’s JavaScript. I don’t think TouchDB/Android supports map functions written in JavaScript; does it, Marty? |
Yes it does, provided you include the TouchDB-Android-JavaScript module. But, I think there is some linkage missing between Ektorp building the marty On Mon, Feb 4, 2013 at 10:59 AM, Jens Alfke [email protected]:
|
For CBLite I had the same problem and as Marty suggested I solved including dependencies versus CBLiteJavascript and setting in my code the Javascript Compiler once before querying first time. CBLView.setCompiler(new CBLJavaScriptViewCompiler()); the same should work for TouchDB using the relative classes. My DB is replicated from an apache couchdb, but unfortunately it seems that some views which works fine on apache couchdb doesn't return the results as expected. Are there some known issue with Javascript compiler? |
I have only tried playing with a trivial javascript view with a map function and it worked fine for me when I tried to query it from curl. (cblite was running behind LiteServAndroid) Can you post the following:
|
I'm using inline views provided by the
CouchDbRepositorySupport
class from Ektorp.Whenever the inline view is reference, I get a
NullReferenceException
at the following line:TDRouter.java:L1327
Checking the debugger tells me that
TDView.getCompiler()
is null.My view repository looks like:
Is this an issue with the TDRouter for TouchDB-Android? or something related to Ektorp?
The text was updated successfully, but these errors were encountered: