Created
December 4, 2010 13:37
-
-
Save tanepiper/728184 to your computer and use it in GitHub Desktop.
Create this in database.js and then in project to var database = require('database'); You can then use database. namespace to access database methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* database.js | |
* The core database setup file for the project | |
*/ | |
/** | |
* The couchdb module instance | |
*/ | |
var cradle = require('cradle'); | |
/** | |
* Load the instance settings | |
*/ | |
var settings = require('./settings'); | |
/** | |
* The couchdb client instance | |
*/ | |
cradle.setup({ | |
host: settings.database.host, | |
port: settings.database.port, | |
auth: { | |
user: settings.database.username, | |
pass: settings.database.password | |
}, | |
options: { | |
cache: false, | |
raw: false | |
} | |
}); | |
var client = new(cradle.Connection); | |
//var client = couchdb.createClient(settings.database.port, settings.database.host, settings.database.username, settings.database.password); | |
/** | |
* Method 1 | |
*/ | |
function methodOne (arg1, arg2) { | |
// Function does something | |
}; | |
/** | |
* The module exports an object to access all database features | |
*/ | |
module.exports = { | |
cradle: cradle, | |
client: client, | |
methodOne : methodOne | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment