Why?
The main reason why this module was written was to get around nw.js requiring sqlite binaries to be built against it. This is a development hinderence and effects deployment.
What?
The module has three components:
A server function that accepts a path to an sqlite3 database and an optional callback. If a callback is omitted the port goes to stdout to be picked up by a parent process.
A client class that accepts a port. It provides a query function that is a synonym for sqlite3's all function. It also provides a run function that allows you to specify the function to be called on the sqlite3 object.
A launchProxy that creates a subprocess server and and ties it to a client returning that client to a callback function.
All callbacks take the form function(error,result)
Example
//Process one.
var sqlproxy = require('sqlite-proxy');
sqlproxy.Server('somedb');
->50453
//Process two.
var db=new sqlproxy.Client(50453);
//More complete and realistic example
sqlproxy.launchProxy(process.env.HOME+'/'+'.myappsdb',function(error,db) {
//Handle error's your prefered way.
db.query('SELECT * FROM mytable WHERE rowid=?',35,function(error,rows) {
var awesomedata = rows[0].awesomedata;
awesomefunc(awesomedata);
});
db.run('run','INSERT INTO mytable (lamedata) VALUES (?)',44,function(error) {
llamafunc(this.lastID);
});
});
npm page: https://www.npmjs.com/package/sqlite-proxy git page: https://www.github.com/x0x7/sqlite-proxy
Other projects: https://www.npmjs.com/~x0x7