From 0df4f6037ca3bde31ab499cf193daeee27bea997 Mon Sep 17 00:00:00 2001 From: brianc Date: Sun, 3 Oct 2010 01:14:19 -0500 Subject: [PATCH] beginnings of actually TDDd query --- lib/index.js | 12 +++++++++++- test/api-tests.js | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 36613829..643e9f49 100644 --- a/lib/index.js +++ b/lib/index.js @@ -57,9 +57,19 @@ Client.prototype.disconnect = function() { }; Client.prototype.query = function() { - + return new Query(); }; +var Query = function() { + EventEmitter.call(this); + var self = this; + process.nextTick(function() { + self.emit('end'); + }); +}; +sys.inherits(Query, EventEmitter); + + var Parser = function(buffer) { this.offset = 0; this.buffer = buffer; diff --git a/test/api-tests.js b/test/api-tests.js index 665812af..1238098d 100644 --- a/test/api-tests.js +++ b/test/api-tests.js @@ -23,6 +23,17 @@ client2.on('ReadyForQuery', function() { client2.disconnect(); }); +var client3 = makeClient(); +client3.connect(); +client3.on('ReadyForQuery', function() { + console.log('client3 ready for query'); + var query = client3.query('create temporary table bang (id integer)'); + query.on('end', function() { + client3.disconnect(); + }); + +}); + // client.query('create temporary table bang (id integer)'); // client.query('insert into bang(id) VALUES(1)'); // client.query('select * from bang',function(err, results, fields) {