From f8962fd03690defb649d7b4e9000f7193384c424 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 21 Nov 2011 11:45:55 +0100 Subject: [PATCH] connection can be binary by default if connection is created with config.binary = true, all queries get executed with binary result unless explicit disabled with binary = false --- lib/client.js | 4 ++++ lib/defaults.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 975eac66..5d1af39a 100644 --- a/lib/client.js +++ b/lib/client.js @@ -20,6 +20,7 @@ var Client = function(config) { this.connection = config.connection || new Connection({stream: config.stream}); this.queryQueue = []; this.password = config.password || defaults.password; + this.binary = config.binary || defaults.binary; this.encoding = 'utf8'; this.processID = null; this.secretKey = null; @@ -173,6 +174,9 @@ p._pulseQueryQueue = function() { p.query = function(config, values, callback) { //can take in strings or config objects config = (typeof(config) == 'string') ? { text: config } : config; + if (this.binary && !('binary' in config)) { + config.binary = true; + } if(values) { if(typeof values === 'function') { diff --git a/lib/defaults.js b/lib/defaults.js index e60c7437..8df164ca 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -14,5 +14,7 @@ module.exports = { //0 will disable connection pooling poolSize: 10, //duration of node-pool timeout - poolIdleTimeout: 30000 + poolIdleTimeout: 30000, + // binary result mode + binary: false }