coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Not working with latest version of node-mysql #109

Open davidleureka opened 11 years ago

davidleureka commented 11 years ago

I'm trying to get persistence-js working with the lastet version of node-mysql using this code:

var persistence = require('persistencejs/lib/persistence').persistence; var persistenceStore = require('persistencejs/lib/persistence.store.mysql');

persistenceStore.config(persistence, 'localhost', 3306, 'test2', 'root', 'xxxxxx'); var session = persistenceStore.getSession();

and I'm running into the following error:

node_modules/persistencejs/lib/persistence.store.mysql.js:21 var client = mysql.createClient({ ^ TypeError: Object # has no method 'createClient' at Object.exports.config.exports.getSession (node_modules/persistencejs/lib/persistence.store.mysql.js:21:24) at Object. (test.js:4:32) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Based on the node-mysql readme file, it looks like the createClient method is no longer supported:

v2.0.0-alpha (2012-05-15)

This release is a rewrite. You should carefully test your application after upgrading to avoid problems. ... The first thing you will run into is that the old Client class is gone and has been replaced with a less ambitious Connection class. So instead of mysql.createClient(), you now have to:

var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', });

So are we limited to using earlier versions of node-mysql or am I doing something wrong?