What are all the methods of $.couch that CouchApp simplifies?

163 Views Asked by At

Based on screencasts and tutorials across the web, I realized that when compared to fetching data like this:

$.couch.db("addressbook").view("addressbook/phonenumbers", {
   success: function(data) {
    for (i in data.rows) {
     id = data.rows[i].id;
     name = data.rows[i].key;
     phonenumber = data.rows[i].value;
     html = '<div class="address">' +
      '<span class="name">' + name + '</span> ' +
      '<span class="phonenumber">' + phonenumber + '</span> ' +
      '<a href="#" class="edit">edit</a> '+
      '<a href="#" class="delete">delete</a> '+
      '</div>';
     $("div#addressbook").append(html);
    }
  }});
 }

CouchApp seems to offer a much more simplified/cleaner way to do so by specifying a file named query.js like so:

function () {
 return {
   "view" : "phonenumbers",
 };
}

And splitting up the html and js across mustache.html and data.js files respectively.

Where is the code that knew to read query.js and knew to call $.couch.db().view with it automagically? Is there more of it? What else does it cover?

I can't find any documentation on what other magical things can be neatly accomplished with CouchApp, can anyone PLEASE point me in the right direction?

2

There are 2 best solutions below

0
On BEST ANSWER

query.js is an Evently thing, you can find more information for your question in a previous answer. Unfortunately I'm not using Evently anymore (switched to AngularJS), so I can't be of much help. Anyway there's not much documentation for it and has been unmaintained for some time, although things may change in the future.

0
On

I'm not entirely sure, but I think you have to write it yourself. (as part of evently)

see: http://couchapp.org/page/evently-do-it-yourself-ii-state (search for query.js on that page) also see: http://couchapp.org/page/evently-primer

for the 'evently primer'

hth some