| 7 | |
| 8 | class Query extends EventEmitter { |
| 9 | constructor(config, values, callback) { |
| 10 | super() |
| 11 | |
| 12 | config = utils.normalizeQueryConfig(config, values, callback) |
| 13 | |
| 14 | this.text = config.text |
| 15 | this.values = config.values |
| 16 | this.rows = config.rows |
| 17 | this.types = config.types |
| 18 | this.name = config.name |
| 19 | this.queryMode = config.queryMode |
| 20 | this.binary = config.binary |
| 21 | // use unique portal name each time |
| 22 | this.portal = config.portal || '' |
| 23 | this.callback = config.callback |
| 24 | this._rowMode = config.rowMode |
| 25 | if (process.domain && config.callback) { |
| 26 | this.callback = process.domain.bind(config.callback) |
| 27 | } |
| 28 | this._result = new Result(this._rowMode, this.types) |
| 29 | |
| 30 | // potential for multiple results |
| 31 | this._results = this._result |
| 32 | this._canceledDueToError = false |
| 33 | } |
| 34 | |
| 35 | requiresPreparation() { |
| 36 | if (this.queryMode === 'extended') { |