使用nodejs构buildCouchDB

有没有人有使用真正的DAL的CouchDB的经验? CouchDB不像其他任何数据存储那里,特别是。 由于其观点的概念,增加了一个有趣的dynamic数据业务逻辑分离…更不用说修改控制应用程序源代码。

注意:像Nano这样的库不是DAL。 它们类似于数据库驱动程序。 直接从业务逻辑中使用Nano会将应用程序绑定到CouchDB。 不是我想要的。 相反,我的定制DAL使用纳米作为驱动程序,但完全将业务逻辑与纳米分离。

问题:我应该阅读的最佳实践或文件? 任何可以在MongoDB和CouchDB之间切换的常见DAL(作为我尝试做的起点)?

您可能想要查看资源丰富的https://github.com/flatiron/resourceful它支持多个数据适配器,包括mongodb和couchdb

这是一个简单的用例:

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); };