node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org ยป

enterprisejs

Enterprise JS

The aim of this tool is to simplify data access by providing an unified and lightweight abstraction layer. One code can be executed against several databases without any change. The tool also adds robustness to application by managing technical plumbing and connection / pooling to the database. As a matter of fact it ensures that resources is correctly release if necessary when all requests are finished and result received. This takes into account the asynchronous aspect of Node.js and its data access drivers.

Installation

npm install enterprisejs

Examples

Accessing PostgreSQL databases

var sys = require("sys");
var enterprisejs = require("enterprisejs");
var driver = enterprisejs.generic;

var uri = "postgresql:localhost:5432/nodejs?user=templth&password=testtest";
var creator = new driver.DatabaseTemplateCreator(uri);

var databaseTemplate = creator.getDatabaseTemplate();

databaseTemplate.doOnData(function(client) {
    client.executeQuery("select * from beatles", function(result) {
       console.log("result = "+sys.inspect(result));
    });
});

Accessing MySQL databases

var sys = require("sys");
var enterprisejs = require("enterprisejs");
var driver = enterprisejs.generic;

var uri = "mysql:/nodejs?user=root&password=testtest";
var creator = new driver.DatabaseTemplateCreator(uri);

var databaseTemplate = creator.getDatabaseTemplate();

databaseTemplate.doOnData(function(client) {
    client.executeQuery("select * from beatles", function(result) {
       console.log("result = "+sys.inspect(result));
    });
});

Documentation

Documentation is a work in progress primarily taking place on the github WIKI.

Goto documentation pages: Documentation

License

Copyright (c) 2011 Thierry Templier (templth@yahoo.fr)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.