Does anyone have any experience with CouchDB where a real DAL was utilized? CouchDB is not like any other datastore out there, esp. due to its notion of views which add an interesting dynamic to data - business logic separation... not to mention revision controlling the application source code.
Side Note: Libraries like Nano are not a DAL. They are akin to a database driver. Using Nano directly from business logic would tie the application to CouchDB. Not what I want. Instead my custom made DAL uses Nano as a driver, but separates the business logic from Nano completely.
Question: any best practices or documents I should read? Any existing DALs that can switch between MongoDB & CouchDB for common things (to act as a starting point for what I am trying to do)?
You may want to check out resourceful https://github.com/flatiron/resourceful it has support for several data adapters, including mongodb and couchdb
Here is a simple use case:
var resourceful = require('resourceful');
var Creature = resourceful.define('creature', function () {
//
// Specify a storage engine
//
this.use('couchdb');
//
// Specify some properties with validation
//
this.string('diet');
this.bool('vertebrate');
this.array('belly');
//
// Specify timestamp properties
//
this.timestamps();
});
//
// Now that the `Creature` prototype is defined
// we can add custom logic to be available on all instances
//
Creature.prototype.feed = function (food) {
this.belly.push(food);
};