Factor out dealing with CouchDB views into some common functions.