sqlite_pool.js
function query(){
		//console.log(arguments[0]);
		var self = this;
		var args = arguments;
		var last_arg = args[args.length - 1];
		var bHasCallback = (typeof last_arg === 'function');
		if (!bHasCallback) // no callback
			last_arg = function(){};

		var count_arguments_without_callback = bHasCallback ? (args.length-1) : args.length;
		var new_args = [];

		for (var i=0; i<count_arguments_without_callback; i++) // except callback
			new_args.push(args[i]);
		if (!bHasCallback && !bCordova)
			return new Promise(function(resolve){
				new_args.push(resolve);
				self.query.apply(self, new_args);
			});
		takeConnectionFromPool(function(connection){
			// add callback that releases the connection before calling the supplied callback
			new_args.push(function(rows){
				connection.release();
				last_arg(rows);
			});
			connection.query.apply(connection, new_args);
		});
	}
function query(){
		//console.log(arguments[0]);
		var self = this;
		var args = arguments;
		var last_arg = args[args.length - 1];
		var bHasCallback = (typeof last_arg === 'function');
		if (!bHasCallback) // no callback
			last_arg = function(){};

		var count_arguments_without_callback = bHasCallback ? (args.length-1) : args.length;
		var new_args = [];

		for (var i=0; i<count_arguments_without_callback; i++) // except callback
			new_args.push(args[i]);
		if (!bHasCallback && !bCordova)
			return new Promise(function(resolve){
				new_args.push(resolve);
				self.query.apply(self, new_args);
			});
		takeConnectionFromPool(function(connection){
			// add callback that releases the connection before calling the supplied callback
			new_args.push(function(rows){
				connection.release();
				last_arg(rows);
			});
			connection.query.apply(connection, new_args);
		});
	}
function query ( ) { //console.log(arguments[0]); var self = this ; var args = arguments ; var last_arg = args [ args . length - 1 ] ; var bHasCallback = ( typeof last_arg === 'function' ) ; if ( ! bHasCallback ) // no callback last_arg = function ( ) { } ; var count_arguments_without_callback = bHasCallback ? ( args . length - 1 ) : args . length ; var new_args = [ ] ; for ( var i = 0 ; i < count_arguments_without_callback ; i ++ ) // except callback new_args . push ( args [ i ] ) ; if ( ! bHasCallback && ! bCordova ) return new Promise ( function ( resolve ) { new_args . push ( resolve ) ; self . query . apply ( self , new_args ) ; } ) ; takeConnectionFromPool ( function ( connection ) { // add callback that releases the connection before calling the supplied callback new_args . push ( function ( rows ) { connection . release ( ) ; last_arg ( rows ) ; } ) ; connection . query . apply ( connection , new_args ) ; } ) ; }
takes a connection from the pool, executes the single query on this connection, and immediately releases the connection
takes a connection from the pool executes the single query on this connection and immediately releases the connection