So I've been reading about CouchDB lately, and I REALLY like it. It seems so simple, yet flexible and I LOVE the RESTful interface. But let's face it - unless you're building a SAP, you'll want your application to serve static HTML with SEO-friendly URLs rather than constant HTTP requests. I haven't actually used CouchDB yet in any project, but I am keen to explore it in near future.
The question is: how can I use it to build a static HTML website, for example a blog? I would like to store all my blog posts in CouchDB and then serve them as HTML, based on categories, tags and date. If I'm understanding this correctly, I would just define a set of shows in my design documents. So for example, in a design document for all posts in the 'Work' category, I would also add a separate function for the show template. However, I have a bit of a problem with storing my HTML inside a JavaScript function inside a JSON file! That's sounds super-painful to maintain. I've had a quick look at CouchApp and it seems to solve this issue, but it doesn't seem to be in active development, hence my question about other possible solutions.
I want to be able to structure my HTML / CSS / JS as I normally would have, but leverage the benefits of CouchDB, if possible, without any external backend. Or even better - I would LOVE to actually define my databases as JSON files, my map functions as regular .js
files and maintain the classic directory structure for everything else, so for example:
db/data
- this holds CouchDB
db/maps
- this holds my map functions
public/
- this holds everything else including other JS, CSS and HTML, like this:
public/css
public/js
public/categories.html
public/posts.html
public/index.html
etc.
Any thoughts on how can I achieve this? Or if it's even possible?
Bonus question: could someone be so kind and explain what reduce functions are? Are they the SQL equivalent of sum
and count
functions? When would I actually use a reduce function? And when would I need to write a custom one?
Thanks!