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) {