can pass config object to native query
This commit is contained in:
parent
569f760b5e
commit
ca9b3cb2cd
@ -46,8 +46,8 @@ p.connect = function() {
|
||||
})
|
||||
}
|
||||
|
||||
p.query = function(queryString) {
|
||||
var q = new NativeQuery(queryString);
|
||||
p.query = function(config) {
|
||||
var q = new NativeQuery(config);
|
||||
this._queryQueue.push(q);
|
||||
this._pulseQueryQueue();
|
||||
return q;
|
||||
@ -79,7 +79,7 @@ var ctor = function(config) {
|
||||
connection._pulseQueryQueue();
|
||||
});
|
||||
|
||||
//proxy some events to active query
|
||||
//proxy some events to active query
|
||||
connection.on('_row', function(row) {
|
||||
connection._activeQuery.emit('row', row);
|
||||
})
|
||||
@ -108,7 +108,11 @@ var connect = function(config, callback) {
|
||||
|
||||
//event emitter proxy
|
||||
var NativeQuery = function(text) {
|
||||
this.text = text;
|
||||
if(typeof text == 'object') {
|
||||
this.text = text.text;
|
||||
} else {
|
||||
this.text = text;
|
||||
}
|
||||
EventEmitter.call(this);
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,18 @@ test('multiple results', function() {
|
||||
assert.equal(row.name, 'Aaron');
|
||||
assert.emits(q, 'row', function(row) {
|
||||
assert.equal(row.name, "Brian");
|
||||
client.end();
|
||||
|
||||
})
|
||||
})
|
||||
assert.emits(q, 'end', function() {
|
||||
test('query with config', function() {
|
||||
var q = client.query({text:'SELECT 1 as num'});
|
||||
assert.emits(q, 'row', function(row) {
|
||||
assert.strictEqual(row.num, 1);
|
||||
assert.emits(q, 'end', function() {
|
||||
client.end();
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user