Refactoring of Database struct

Immutable state moved to shared DatabaseContext.
Database now embeds/extends DatabaseContext.
Validation functions are now run

Add validation fn as "validate_doc_update" property of _design/channels.
Works just like in CouchDB.

Limitation: After changing the function source in the design doc, you
have to restart the server before it'll start using the new function.