Browse files

Set-up library to be used a node library installable via npm. In fact,

it's published on npm right now.
  • Loading branch information...
1 parent ff9084b commit dd1c7c4c10e56d26416103c4e94969046ae57605 @zefhemel zefhemel committed Sep 20, 2010
Showing with 11 additions and 14 deletions.
  1. +7 −4 README.md
  2. +2 −8 lib/persistence.store.mysql.js
  3. +2 −2 test/node-blog.js
View
11 README.md
@@ -418,6 +418,10 @@ Example:
Using persistence.js on the server
==================================
+Installing `persistence.js` on node is easy using [npm](http://npmjs.org):
+
+ npm install persistencejs
+
Sadly the node.js server environment requires slight changes to
`persistence.js` to make it work with multiple database connections:
@@ -431,11 +435,10 @@ An example `node.js` application is included in `test/node-blog.js`.
Setup
-----
You need to `require` two modules, the `persistence.js` library itself
-and the MySQL backend module. Also make sure the MySQL library
-is located (or symlinked) from the current directory:
+and the MySQL backend module.
- var persistence = require('./persistence').persistence;
- var persistenceStore = require('./persistence.store.mysql');
+ var persistence = require('persistencejs/persistence').persistence;
+ var persistenceStore = require('persistencejs/persistence.store.mysql');
Then, you configure the database settings to use:
View
10 lib/persistence.store.mysql.js
@@ -4,24 +4,18 @@
* Easy install using npm:
* npm install mysql
*/
-var persistencejs = require('./persistence');
-var persistence = persistencejs.persistence;
-var sql = require('./persistence.store.sql');
var sys = require('sys');
+var sql = require('persistencejs/persistence.store.sql');
var mysql = require('mysql');
-persistencejs.console.log = function(s) {
- sys.print(sys.inspect(s) + "\n");
-};
-
var db, username, password;
function log(o) {
sys.print(sys.inspect(o) + "\n");
}
-exports.config = function(persistence, hostname, db, username, password) {
+exports.config = function(persistence, hostname, db, username, password) {
exports.getSession = function() {
var that = {};
var conn = new mysql.Client();
View
4 test/node-blog.js
@@ -31,8 +31,8 @@
var sys = require('sys');
var parseUrl = require('url').parse;
-var persistence = require('../persistence').persistence;
-var persistenceStore = require('../persistence.store.mysql');
+var persistence = require('persistencejs/persistence').persistence;
+var persistenceStore = require('persistencejs/persistence.store.mysql');
// Database configuration
persistenceStore.config(persistence, 'localhost', 'nodejs_mysql', 'test', 'test');

0 comments on commit dd1c7c4

Please sign in to comment.