Views Maps Queries Javascript and Java

Hello,

I have been examining the Android couchbase lite GrocerySync application and have some questions.

  1. Creating views using Java: The code for the GrocerySync app creates views with Mappers directly in it’s Java code. Is it good practice to do this or is it better to create a design document and views and maps using javascript and load those views into my couchbase server?

  2. Creating view using Javascript: I saw some other Java examples where a Javascript string is supplied as the mapper in Java code. I have a feeling I’m actually supposed to create views and maps with javascript in a design document and then load that to my couchbase server externally from my application all together. The applications with use those views by name rather than create views from inside of themselves. Does this sound like the correct practice? Will it lead to more efficient use of couchbase?

  3. How much should the map do?: I wrote a Mapper in my Android Java application to get precisely what was needed. For instance, to get items relevant for “today”, I filtered on a date field and my mapper checked to see if the date was within today’s date. After reading more I see that It may be better to write a Mapper that simply outputs documents by date, and then use parameters with my query to set startkey and endkey to filter the data. What is a more accepted practice and why?

  4. Emitting values from maps: I’ve seen Java examples where the Mapper emits the entire document as it’s value. I have read that maps should only emit the minimal keys to allow the client to access the required document. Does it make the view inefficient to provide values back from the map output? Does that view get too big? What if any are the problems doing this practice?

  5. Development versus production views: I read about creating design documents and promoting them to production. Furthermore if I create views in a design document, I can access them via REST. I don’t think I can access the views created from inside the GrocerySync application. I read that having temporary views was expensive and not a good idea. Considering the views created in the GrocerySync Java code, what kind of views are they? temporary? development? production? Can I access those views via REST? Are those views recreated everytime the application runs. Is the way they are created and used considered good practice?

  6. Many views on same design document: If I keep creating more and different views with Mappers programmatically as does the GrocerySync application are all the views associated with the same design document? I read that having many views on a design document can be a bad thing. What are your thoughts on this?

Thanks
Brian