Changeset: ee3e06d6a293 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee3e06d6a293
Modified Files:
clients/nodejs/monetdb/mapiclient.js
clients/nodejs/monetdb/package.json
Branch: default
Log Message:
Node.JS connector: Q integration from Robin
diffs (78 lines):
diff --git a/clients/nodejs/monetdb/mapiclient.js
b/clients/nodejs/monetdb/mapiclient.js
--- a/clients/nodejs/monetdb/mapiclient.js
+++ b/clients/nodejs/monetdb/mapiclient.js
@@ -162,9 +162,12 @@ MonetDBConnection.prototype.prepare = fu
return this;
}
-MonetDBConnection.prototype.disconnect =
+MonetDBConnection.prototype.disconnect =
MonetDBConnection.prototype.close = function() {
this.do_close = true;
+ if (this.queryqueue.length < 1) {
+ next_op.call(this);
+ }
return this;
}
@@ -467,12 +470,42 @@ function __check_arg(options, argname, t
}
function __get_connect_args(options) {
- __check_arg(options, 'dbname' , 'string' , 'demo');
- __check_arg(options, 'user' , 'string' , 'monetdb');
- __check_arg(options, 'password', 'string' , 'monetdb');
- __check_arg(options, 'host' , 'string' , 'localhost');
- __check_arg(options, 'port' , 'number' , 50000);
- __check_arg(options, 'language', 'string' , 'sql');
- __check_arg(options, 'debug' , 'boolean', false);
+ __check_arg(options, 'dbname' , 'string' , 'demo');
+ __check_arg(options, 'user' , 'string' , 'monetdb');
+ __check_arg(options, 'password', 'string' , 'monetdb');
+ __check_arg(options, 'host' , 'string' , 'localhost');
+ __check_arg(options, 'port' , 'number' , 50000);
+ __check_arg(options, 'language', 'string' , 'sql');
+ __check_arg(options, 'debug' , 'boolean' , false);
+ __check_arg(options, 'q' , 'function', undefined);
+
return options;
}
+
+/* Q integration, <[email protected]> */
+['request', 'query', 'prepare'].forEach(function(funToQ) {
+ var funQ = funToQ + 'Q';
+ MonetDBConnection.prototype[funQ] = function() {
+ if (this.options.q == undefined) {
+ console.warn('We need Q as part of the connect options
(q).');
+ return;
+ }
+ return this.options.q.npost(this, funToQ, arguments);
+ }
+});
+
+exports.connectQ = exports.openQ = function(options) {
+ if (options.q == undefined) {
+ console.warn('We need Q as part of the connect options (q).');
+ return;
+ }
+ var deferred = options.q.defer();
+ var conn = exports.open(options, function(err) {
+ if(err) {
+ return deferred.reject(new Error(err));
+ }
+ deferred.resolve(conn);
+ });
+ return deferred.promise;
+}
+
diff --git a/clients/nodejs/monetdb/package.json
b/clients/nodejs/monetdb/package.json
--- a/clients/nodejs/monetdb/package.json
+++ b/clients/nodejs/monetdb/package.json
@@ -1,6 +1,6 @@
{
"name": "monetdb",
- "version": "0.1.6",
+ "version": "0.1.7",
"description": "Connect MonetDB and node.js",
"main": "mapiclient.js",
"author": "Hannes Mühleisen <[email protected]>",
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list